Update Two Records In One Table From One Record In Another

Oct 14, 2004

Hi,

I am creating a league table for my soccer team.

I have a database with these tables:

1. teams
2. league_table
3. fixtures

The Fixtures Table has a lookup where it pulls in the opposing teams - home_team & away_team. There is also Home_goals & away_goals. How can I get the fixtures table to update each teams goals in the league_table table where these details are held.

Anyone any ideas on how this is done?

Thanks in advance.

View Replies


ADVERTISEMENT

General :: Update Record ID To Another Record ID In Same Table And Update Related Records

Aug 22, 2013

I have a table called tblCompanies. When a company acquires another company, I need a method by which the acquired company's CompanyID (PK) can be updated to the new company's CompanyID (PK). I also need to be able to update all related CompanyIDs (FKs) to the new value in related tables.

In cases in which the new company does not have an existing record, there is no problem: the company name simply gets changed to the new company and the existing CompanyID is maintained. I then use an audit table and Track Changes function to keep track of the company name data and a union query to keep the old names in the selection lists.

The problem is when both companies already have existing records in the table.

So, let's say I have records for Company A and Company B. Company A merges with Company B and Company B is now the main record. What is the best, simplest and easiest way to update the CompanyID (PK) from A to B and change the CompanyID (FK) to the new value in all related tables?

I am envisioning a pop-up form that directs the user to select the new company and then an update query happens behind the scenes... but exactly how does the criteria for the update query get selected and how do all the related tables get updated? My vba skills are pretty basic, will I need extensive coding to do something like this?

View 6 Replies View Related

Modules & VBA :: Loop Through Records And Update Listbox In Each Record

Sep 11, 2013

I have a table with a multi-select listbox as one of the fields. I want to loop through the recordset (table) and changes the listbox selections for each record.

To go into a little more detail, the table (tblEmail) has a field (Label) that is a multi-select listbox. The listbox pulls from another table (tblLabel). I want to loop through records in tblEmail and edit/change the Label(s) for each email though VBA.

I've tried doing something like this:

Code:
With rst
.MoveFirst
Do Until rst.EOF
.Edit
!Label.Selected(0) = True
.Update
Loop
End With

However I get an error that says "Run-Time Error '438' Object doesn't support this property or method" ...

View 2 Replies View Related

Queries :: Update Query (table To Table) Not Updating All Records

Nov 26, 2013

I'm using an UPDATE query to update records in one table (tblMain) from another table (tblTemp)

Here is my SQL :

Quote:

UPDATE [tblMain]
INNER JOIN [tblTemp] ON [tblMain].[MainField1] = [tblTemp].[TempField1]
SET [tblMain].[MainField2] = [tblTemp].[TempField2];

I only want to update the records in tblMain which have a corresponding record in tblTemp (linked by MainField1 / TempField1)

If any record doesn't appear in tblTemp, I want tblMain to retain the existing value for that record.

However, it appears that in such situations, the record in tblMain has it's MainField2 value set to null / ZLS.

I've tried using LEFT JOIN and RIGHT JOIN and also tried WHERE clauses but the result is the same every time.

View 3 Replies View Related

Modules & VBA :: Identify Strings Into 2nd Table Records Then Update 1st Table

May 5, 2015

MS Access 2013: I have two database tables as below:

tbl1_MainDB --- It has a field named as "City" where I get huge data for some city names. Sometimes This field may have some unknown/new names which are not listed in our 2nd table ("tbl2_RefrDB")

tbl2_RefrDB --- It's a reference table which has raw names for cities, and then standard names of their city and state in another fields.

Target --- I want to create a VBA prorgram (Sql query) which can look from tbl1_MainDB.[City] to tbl2_RefrDB.[Raw_City] field, and if found then pick the "Standard_State" and "Standard_City" record values from there, and update into the 1st table "tbl1_MainDB".

...if not found in "tbl2_RefrDB" table, then user can be informed & ask for updating the new/unmatched city record as a new record in this table.

Attached sample database for more details.

View 4 Replies View Related

Modules & VBA :: Update Record Based On Related Records Completed

Dec 4, 2014

I have 2 tables, one is like a main table, containing all of the main data, such as a Job Number, Customer, Quantity, etc. I have a second, related, table that acts a breakdown of information. There may be several related records to one main record, it entirely depends on the nature of the job.

What I'd like to do is run a function that looks at a main record, checks if all the related records COMPLETED field is ticked and then tick a field in the main record. I only want it to do this for records where all of the related records are COMPLETED.

View 3 Replies View Related

Update Certain Records In Table.

May 7, 2005

Hi there all,

I am looking for a way to update certain records in a table with an incremented value of +1 each time.

For example, TBL_MAIN will have fields REF_NO and INCREMENT_VALUE. In field REF_NO, the same record may appear more than once and the INCREMENT_VALUE field needs to update by +1 each time. I have attached a simple snapshot of the table. In this example, I would like ref ABC123 have it's INCREMENT_VALUE increased by +1 each time following on from the last incremented value of 12460. I believe this may involve DMAX function, For Next loop and possible DAO recordset code but don't really know where to start!

Rgds,
Paul.

View 2 Replies View Related

Update Records From One Table To Another

Mar 9, 2008

Hi

This may seem a really dumb question but I just can not get my head around the best way of solving it.

I have two tables orders and orders_tmp
the table orders is created form the orders_tmp table. The order is created by a single field createorder (yes/no)from the order_tmp table. I run an append query to copy the records into the orders table. this woks fine.

The problem I am trying to solve is how do I now go back and change the order for what ever reason. I need the order_tmp table to now also include my existing order.

Help please

View 2 Replies View Related

Count Records In A Table And Update To Another Table

Feb 25, 2005

I need to use an update query to count the number of selected records and then place this number in another table using an update query. The table has a field with a 1 in that field for all records to do the counting. I know I can use forms and subforms, but the data needed is too massive to be practical. Thanks Abe

View 2 Replies View Related

Forms :: Add Records To One Table And Update In Another Table

May 16, 2014

I have three tables: Members, Promotions, Ranks.

Members has all the data specific to a member and contains just one record per member.
Promotions contains information on member promotions and contains multiple records per member.
Ranks is a table of ranks and data specific to each rank such as name, description, title, fee.

I have a Promotion Detail form used for adding new promotions. I use some VBA that auto completes other fields on the form with information from the Ranks table based on the rank selected. The user has the ability to modify any of the data.

What I would like to do is update the Member's title (in the Members table) when a new promotion is added to the Promotions table. Their title is determined by the information from their latest promotion.

I'm trying to automate as many processes as possible.

View 5 Replies View Related

Update And Compare Table Records

Sep 1, 2005

Hi
I'm using MS Office 2000, I have an Access database table that contain many fields, namely I need to update FieldA from an Excel Spreadsheet according to the specified primary key of CustomerID. Is there a way to write automate process to import the records from an excel spreadsheet and then place those records in FieldA of the Access Database according to the corresponding CustomerID? The reason I ask is that these two fields are not exactly in the right order in my spreadsheet and my table and to do it manually will take lots of effort.

Your prompt response is greatly appreciated

Thanks

View 3 Replies View Related

Can't Update Records In Linked Table

Apr 2, 2006

I have done everything I can think of to remedy this, but I can't figure out why this is happening. I have a linked table from excel that contains 5 fields for each record. I have a table in access with matching records and 20-30 fields. The linked spreadsheet is used when adding records. I have a query that queries both tables to get all data from both and a form based on that query where others can pertinent data for the records resulting from the query. My problem is that when I open the form the new records that were added in the linked file are there but all the fields from the access table cannot be updated. I have looked every place I know to look for record locks, read only options, everything I can think of why i cannot update these records and I am coming up empty. I checked my join properties and selected the only one that actually displays the linked records when the query is run (not sure the name of the join but it's #2 of 3 join properties options (in Access 2002). maybe I am just overlooking something simple? Do you have any ideas what I can do here?

Thanks!

View 1 Replies View Related

Update Records In A Table Same Time

Oct 12, 2004

Hi all,

I had a table which had a yes/no check box. Is there any way to update all the checkboxes
in the table based on a value in a field same time?????


thanks

View 6 Replies View Related

Noob - Update Record In Table

Sep 13, 2005

Hi all,

First of all....my first access database and I'm still a VB newbie...so my apologies if this is a stupid question. I tried searching the web and this forum but could'nt find what I was looking for.

Basically, I am developing an authentication script for a training tutorial. The user either logs in with there existing info, or prior creates a new record. When they login they also select a team (eg Team 1, 2, 3, 4, admin and so on). This is selected from a combo box - the teams are on their own table.

I have another table storing the user info - name, password, the users team...and so on. When they log in and the team selected does not match the team in 'tblusers' - I want access to change the record to reflect the new team.

Can anyone help me with the code to make this happen? So far I have -

If Me.defineteam.Value <> DLookup("Team", "tblusers") Then
MsgBox "You have changed team. This will now be updated", vbOKOnly, "Required Data"
GoTo verifypassword:
End If

This authenticates the team....I just don't know how to replace the one in the record with the value in the combobox.

Thanks for your help.....I'm losing hair!

cheers

Sd

View 7 Replies View Related

Update Query Not Updating Records In Table

Nov 3, 2005

I created an update query that says it has successfully updated 600 records, but when you go into the table, it has not been updated. I am working with an .mde. Does that make a difference?

I first created a select query to find everyone in TX. Then I changed it to an update query to change all TX to CA. Since it did not update the table, I tried running the update query again and this time it says there are not records to update (since it uppposedly updated my 600 records).

Your help is appreciated.

View 1 Replies View Related

General :: Form To Update Records Within A Table

Jan 9, 2014

Still working on the registration and badge print system for their upcoming exhbition the company I do a bit of work for. Managed to solve most of my problems but have got stuck here.

Basically each of the badges have a barcode (code 39) on them which is in the following format...
*1000000123$M*

(*'s required for the barcode to work, the numbers are the badge number and the $M is the enter command (i think))

Basically we need a form that allows us to scan the barcode (the number of the barcode is the Primary Key in the tbl_Attendees), and for this to update the "Attended" (Yes/No) field to yes. This bit I can do with a simple update query, but we need some form of confirmation, something simple like a line of text showing up on the form saying

"Joe Bloggs of Leeds registered as Attended".

View 3 Replies View Related

Update A Record Of One Table And Save The History Of Changes In Another.

Jun 10, 2007

Hello!
I am trying to update the current status of an asset, when it was returned or checked out. At the same time, save the changes in a history table to record all the changes in past. I can do individually from different tables and different forms, but I would like to do from one form and one record entry. Is it possible? If so can anybody help?
Thanks
JVirk

View 4 Replies View Related

Modules & VBA :: Update Record With Info From Another Table?

May 12, 2014

I have a database which tracks product batches test results and then any reported issues.

I have one table tblOne with [Batch Number] and [Release Time/Date].
The 2nd Table tblTwo [Problem/Issue] at [Time/Date].

What i need to do is get the last batch number from table one which would have been released.

Example:

Batch: 275 Released: 21/09/2012 06:15
Batch: 453 Released: 30/09/2012 07:20

Problem: Wrong Batch Time/Date: 21/09/2012 08:20 Batch:????

How would i update table with correct batch in tblTwo

View 3 Replies View Related

Update Separate Table When Record Is Edited

Aug 5, 2015

I have a form where a user can change the scheduled start date for a job. On a sub form on the same screen is a list of notes relating to that job.

Any notes added, automatically have todays date and are locked when the user clicks off.

When the scheduled start date is changed I need a note to be made. Either forced, then entered by the user or automatically.

I was thinking of making the scheduled start appear in a small form and the button to make it come up could add a new note on the click event (possibly in a message).

Or even better (probably harder) any time the value is changed in the form a new note is added.

Other options could be a pop up form to add one note on a change.

View 4 Replies View Related

SQL SP To Update 2 Records Using A Value Found In A Completly Seperate Table

Nov 9, 2005

OK this may be a bit of a weird one.

Here are my tables:

Table: Relationship
PK: RelationshipID int (Indexed No Dup)
FK: ContactID int (Indexed No Dup)

Table: Contact
PK: ContactID int (Indexed No Dup)
FK: RelationshipID int (Indexed Dup Allowed)

I also have following Local vars:
@Contact1 int
@Contact2 int

How do I create an UPDATE statement that will read RelationshipID in Relationship where Relationship.ContactID=@Contact1 and use it as the value to update the Contact.RelationshipID for all records in Contact where Contact.ContactID = @Contact1 or @Contact2

Hope this makes sense?

Also please let me know if I should post this in the SQL area instead.

View 1 Replies View Related

Modules & VBA :: How To Loop Update Query On All Records Of A Table

Sep 2, 2014

I've set a database which has a table in which there are 2 fields "Account" and "Total Accounts". I want to have the amount of total summation of accounts in "Total Accounts" field of each record, which is the result of summation of "Account" values in all previous records till the current one. In order to do this purpose, I copied the value of "Amount" field of each record into "Total Accounts" field of the same record, at first. Then, I tried to add the amount of "Total Accounts" field of every record with just the amount of "Total Accounts" of previous one to earn the actual total amount of that record. I found that I need a VBA loop to do this query for all records (except first record) and so I code it as below, but it has the Run-time error '424' : Object required and it seems that I am in a mistake in definition of strSQL variable:

Code:
Private Sub doDataSegm_Click()
Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set dbs = CurrentDb()
Set rs = dbs.OpenRecordset("Table1", dbOpenTable)

[Code] .....

View 3 Replies View Related

Queries :: Update Query - Add Records To A Join Table?

Apr 11, 2013

I have 2 tables that are joined by a many to many table:

tblProductInfo
- ProductID

tblProductLinerMM

- PLProductID (FK to [tblProductInfo].[ProductID])
- PLLinerID (FK to [tblLiner].[LinerID])

tblLiner

- LinerID

I have a range of products that each use 2 liners. An inner liner and an outer liner. I need to add 2 records per product to the tblProductLinerMM table.

for example

tblProductInfo has the following records:

- 2138557
- 2378954
- 4387657

tblLiner has 2 liners in particular that relate to these products:

- L5475
- L5468

I need to create the following records in tblProductLinerMM preferably with the use of a query :

- 2138557 | L5475
- 2138557 | L5468
- 2378954 | L5475
- 2378954 | L5468
- 4387657 | L5475
- 4387657 | L5468

View 1 Replies View Related

General :: Append And Update Records Daily From One Table To Another

Jan 9, 2014

I need to know the best way to append,

table1=productid,ProductName,Qty to table2=Productid,productName,Qty,date daily

I want to be able to append Records daily from table1 into table2 OnClose. But i do not want duplication of record in the same day.

If changes occurs in table1 after append,table2 should be updated using If conditions

View 1 Replies View Related

Modules & VBA :: Split Table Record Into Multiple Records / Rows In A New Table

Nov 10, 2014

In a situation where I imported an excel file with so many columns and split them into two temp tables and they are linked using a key.

the data has a fixed part lets say

Field1....Field2.....Filed3.....Field4...then Field5.....Field6.....Field7....Field8 is the same data range as Field9...Field10...Field11...Field12. I would want to split this data into multiple rows like this

Field 1 Field2 Field3 Field4 Field5 Field6 Field7 Field8
Field 1 Field2 Field3 Field4 Field9 field10 field11 field12 and so own...

What is the best approach?

View 3 Replies View Related

Modules & VBA :: Generate Multiple Records In One Table From Single Record In Another Table

Sep 20, 2014

I am building a simplified re-order point system - if inventory position drops below a certain level (the yellow level is this case) one or more purchase order lines has to be created in another table.

I have one table with the following field and data:

ItemId Red Yellow Green Multiple Inventory position
0001 10 30 50 5 45
0002 5 40 47 5 23
0003 11 20 30 10 5

I would like to generate new records (in another table) based on the above fields and three records.Basically the end result should look as the following:

ItemId Qty Start inv Aggregated inventory Prioritization
0002 5 23 28 Yellow
0002 5 28 33 Yellow
0002 5 33 38 Yellow
0002 5 38 43 Green
0002 5 43 48 Green
0003 10 5 15 Red
0003 10 15 25 Yellow
0003 10 25 35 Green

The logic is quite simple - if inventory position is less than the yellow value new order lines should be created in multiple qty (based on the multiple field) until the aggregated value (in table 2) is above the green value.The priotization value should be based on the start inv (in tbl 2) compared to the values in red, yellow and green in tbl 1.

View 8 Replies View Related

Queries :: Update Table If A Field Is Blank Without Clicking Through All 5K Records

May 7, 2014

I am putting the finishing touches on a DB and have come up with a a problem which I cannot solve. I have code on my data entry form that concatenated the days and times of up to five days. That is : [Day1] & " " & "@" & " " & Format([Time1],"h:nn AM/PM") & " " & ";" and so forth for five days. It has a complicated (for me) nested IIF statement and it works fine on the form. But I have now transferred the data from an old DOS DB and I do not want to go through almost 5K records just to update three fields.When I tried to do it in an update query, it said that the string was too long for the update. My update is:

IIf([Day5] Is Not Null,[Day1] & " " & "@" & " " & Format([Time1],"h:nn AM/PM") & " " & ";" & " " & [Day2] & " " & "@" & " " & Format([Time2],"h:nn AM/PM") & " " & ";" & " " & [Day3] & " " & "@" & " " & Format([Time3],"h:nn AM/PM") & " " & ";" & " " & [Day4] & " " & "@" & " " & Format([Time4],"h:nn AM/PM") & " " & ";" & " " & [Day5] & " " & "@" & " " & Format([Time5],"h:nn AM/PM"),IIf([Day5] Is Null And [Day4] Is Not Null,[Day1] & " " & "@" & " " & Format([Time1],"h:nn AM/PM") &

[code]...

how to update the table if a field is blank without clicking through all 5K records? I have tried simple concatenation, but I usually get a lot of extra @ in the field.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved