|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
October 29th, 2003, 05:16 PM
|
Registered User
|
|
Join Date: Oct 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Updating Two Tables from Form Input
I created a form that updates a table. I would like that data to be updated to another table also. Can I do that in the form? Any other way?
PamS
|
October 29th, 2003, 07:07 PM
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
What is the relationship between one table and the other?
there are ways to do this, however, there may be a simpler way to fix the problem.
You can either do this by using append queries and a combination of find unmatched queries.
What are you trying to do?
Please also provide table structure.
Sal
|
October 30th, 2003, 11:24 AM
|
Registered User
|
|
Join Date: Oct 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
OK - I am importing two reports that are missing two depts. During the import I create records for these depts and then want the user to key in the rest of the info (dollar amts). The key to file A is "A" + Dept + Date and the key to file D is "D" + Dept + Date, the only difference is the A or D. I made two tables because I have to subtract the "D" amts from the "A" amts for a report. (ALL minus DEBITs gives me CREDITS.) When the user keys in the amts I would like to update both tables. The entry form only shows the two missing depts. Should I create an append query to run after the form, or can I do an update query using data from one table to update the other table?
PamS
|
October 30th, 2003, 11:42 AM
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
If the only difference between the wto tables is the A andD fields, keep all of the info in one table. Your key will still be unique, because your A and D will make it unique. All you would have to do to get totals would be a big addition/substraction Sum(A)-Sum(B), and you would get the result. This may also simplify data entry.
I hope that makes sense.
Are there any other fields on each table that may be different from the other table? or contain different data?
Sal
|
October 30th, 2003, 12:21 PM
|
Registered User
|
|
Join Date: Oct 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Even if I have the info in one file I still need the A and D record to be duplicated. How do I do that without keying in twice. The fields are all named the same (it's an AR aging report).
How do I subtract one record from another? Do I create a query to isolate the"A" and then another for the subtraction?
PamS
|
October 30th, 2003, 12:46 PM
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Do this tables have any referential integrity or other constraints?
The only way of doing this may be by using ADO to insert record to both tables. When a record is inserted to table A, a date is added. is this done by the user or by a default Date() value in the Date field? If this is done with a default value, chances are a record A could have a different date from record B on table B. By using ADO and unbound colums, you can set a variable date that gest inserted to both tables. the problem would be when a record is edited. Would you have to change the record on the other table as well? If yes, how do you compare both tables with different keys?
Do you know ADO? if not I will look for some samples for you.
Sal
|
October 30th, 2003, 02:46 PM
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
If you create one table. Put the following fields, or equivalent fields
Dept
Date
AAmount
DAmount
you can create a query an insert a calculated field
NewField: [AAmount]-[DAmount]
And it will give you your result.
You are trying too hard by duplicating the info in two tables. One table is enough and it will not have any issues on joining one table to the other. Anyway, you may not even need to keep the A and D or two dates, or two dept.
Will this work for you?
Sal
|
|
|