Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2005

Tip: Looking for answers? Try searching our database.

copy autonumber from one table to another

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Noemi - 11 Mar 2005 04:01 GMT
Ttable 1 is updated when a button is clicked on my form and Table 2 is
updated from the sub form when the same button is clicked.

What I would like to do is have the autonumber field which is the primary
key in the 1st table to copy into my 2nd table once a query is run to update
the 2 table from the subform. I have been advised how to run the query from
the form but dont know how to store the autonumber which is generated as the
record is being added so I can copy the number into the second table, however
the autonumber might be duplicated in the 2nd table due to the subform has
multiple rows but they all fall under the one autonumber.

I hope someone can help me.

Thanks
Nikos Yannacopoulos - 11 Mar 2005 08:32 GMT
Noemi,

How are you doing the updates? Recordset operations, or SQL Append queries?
In a recordset operation, the autonumber field value is assigned the
moment you run .AddNew, so you can store it in a variable anytime after
that (and before you move to another record or close the recordset), and
use it in adding the records tothe second recordset.
In the SQL Append queries case, I'm afraid it is rather tricky; I can't
think of an easy way to do it, except by first appending the record and
then doing a DLookup based on the other fields (their values still
available form the form controls). i would opt for the recordset ops though.
If you need more detailed help, please post your current code.

HTH,
Nikos

> Ttable 1 is updated when a button is clicked on my form and Table 2 is
> updated from the sub form when the same button is clicked.
[quoted text clipped - 10 lines]
>
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.