PDA

Click to See Complete Forum and Search --> : add new record in table in access


feeder23
Aug 5th, 2005, 09:57 AM
Hi,

I have some troubles with code in access vb.

Well, I made it already possible to add new records with textbox and button with the code:
CurrentDb.Execute "INSERT INTO TblOplossingen (Oplossing) VALUES ('" & TypnieuweOplossing.Value & "')"

Now in my TblOplossingen I have the field autonumberfield.
So when I push on the button, the new record will be placed and also a new number in the autonumberfield.
But this is not the only thing I want.

When I push on the button, I want too that the autonumberfield of my new record will be added in another table. And this while the new number of the autonumberfield of my new record is not visible in the form.

Has anybody a solution for that problem?

greetz

Ecniv
Aug 8th, 2005, 04:26 AM
Since you updated via an execute, you will need to use the max function in an sql statement, possibly in another Insert Into with the max as a sub query to get the max number in the id field... Not too sure.
The alternative is to use several recordsets to pull the information you want and write it back to the db.