Retrieve AutoNumber Problem

lfazenbaker

New member
Local time
Yesterday, 22:10
Joined
Sep 16, 2005
Messages
7
Can someone please tell me what I'm doing wrong here. I have just added a record to a table. I would now like to get the record number (FamilyID), which as an AutoNumber field, and pass it to another form. My query is giving me an error that says,
"A RunSQL action requires an argument consisting of an SQL statement."

Here is the code snippet:
DoCmd.RunSQL "SELECT FamilyID FROM Families WHERE LastName = '" & _
txtLast.Value & "';"

Thanks,
Lisa

P.S. No one ever replies to my posts. Please respond if you can help. :)
 
Do you want to Link two Forms.

What do you mean pass the FamilyID to another form.
 
Pass to another form

The first form is the first half of an application. The second form is the second half. When the user clicks "next" on the first form, a new record is added and the second form is opened. When the user completes the info on the second form, I want to update the record that was created in the first form with the data in the second. The problem is that I can't seem to get the row ID number to the second form so I can identify the row to update.

Thanks,
Lisa
 
Try:
DoCmd.RunSQL "SELECT FamilyID FROM Families " & _
"WHERE LastName = '" & Me.txtLast.Value & "'"
 
Last edited:
Use the DMAX function to retrieve the last Autonumber assigned. You can only run Action queries in code, not select queries.
 
Thanks, Scott! Worked Great!! :)

Use the DMAX function to retrieve the last Autonumber assigned. You can
only run Action queries in code, not select queries.
__________________
Hope this helps: Scott
 

Users who are viewing this thread

Back
Top Bottom