I'm having trouble with an append query involving variables supplied by the user. I have input boxes pop up to enter a ticket number and initials. The query is supposed to copy info from a table, along with the 2 inputs from the user, into another table. it works with just the first input, but adding the second gives a parameter error. Here's a condensed version of my code:
-
Dim VarTermTicket As String
-
Dim VarTermedBy As String
-
-
VarTermTicket = InputBox("Please enter term ticket:")
-
VarTermedBy = InputBox("Please enter your initials:")
-
-
AppendTermedUser = "INSERT INTO TermedSabre (ID, FirstName, LastName, TermTicket, TermedBy, TermDate) SELECT SabreUsers.ID, SabreUsers.FirstName, SabreUsers.LastName, " & VarTermTicket & ", " & VarTermedBy & ", Date() AS Expr1 FROM SabreUsers WHERE SabreUsers.ID = " & UserID & ""
-
DoCmd.RunSQL (AppendTermedUser)
When I run it, the inputs pop up just fine, I enter let's say 1 for the ticketNumber and "SSD" for initials and I get a box saying "Enter Parameter Value" for SSD. If I take out everything for the initials/varTermedBy the query works just fine, so I think I must be referencing it incorrectly or using the quotes wrong. Any help out there?
Thanks
PS. I should add that if I cancel out of the box asking for the parameter it gives me "run-time error '3270': Reserved Error"