Append Query Taking ID from a Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Have been away from Access for a few years. I need to create an append query
that runs when I add a new record and need to know how to make it take the
GuestID from the form that the we will be using. I know its a "Me" command.
Note: I am good at Access but not at commands. (This is a for a church
project).
 
In the AfterInsert event procedure of your form, concatenate the GuestId
into a string and execute that, e.g.:
Private Sub Form_AfterInsert()
Dim strSql As String
strSql = "INSERT INTO ... WHERE GuestId = " & Me.GuestId & ";"
dbEngine(0)(0).Execute strSql, dbFailOnError
End Sub

To see an example of what the string should look like, switch your existing
append query to SQL View.

More info on executing a string like that:
http://allenbrowne.com/ser-60.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 
Back
Top