View Full Version : Assigning a field value to variable


aecarpin
03-04-2005, 01:19 AM
I would appreciate a hand from some of you great wizard out there please.
I am trying to assign the value of the primary key (autonumber)newly of a added record to a variable so I can use it to add a new record in another related table. I don't know what the syntax should look like. Please help!!!!

Function AddMembers(rstTemp As DAO.Recordset, strName As String, strAddress As String)
Dim VarMemberID As Long
' Adds a new record to a Recordset using the data passed
' by the calling procedure. The new record is then made
' the current record.
With rstTemp
.AddNew
!Name = strName
!Address = strAddress
.Update
.Bookmark = .LastModified
VarMemberID = MemberID 'This is not working!!! I want to use the value of varMemberID to add a new record in another table
End With

End Function

pbaldy
03-04-2005, 10:32 AM
Try putting that line right before the .Update line.

aecarpin
03-05-2005, 12:28 PM
Very kind of you Paul, I will try that. Thank you. :D