I'm trying to update records in my form. It's a restaurant reservation system. Given the Table #, the form can let the user input the Customer ID of the person reserving, the reservation time and date. But when I click on the "update" button in my form, a text box will pop up with this:
And whatever I put in it, the runtime error "too few parameters. expected 1." pops up. Sometimes a "Reserved Error" will pop up. Could someone help me? It's the last step before I could finally finish this project.
This is my code for updating the record:
Private Sub Command8_Click()
On Error GoTo errHandling
Dim strSQL As String
strSQL = "UPDATE tblReserve SET CustomerID = " & """" & Me.txtCustID & """" & _
", ResDate = " & """" & Me.txtResDate & """" & ", ResTime = " & """" & Me.txtTime & """" & " WHERE TableNum =" & Me.TableNum
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
CurrentDb.Execute strSQL, dbFailOnError
DoCmd.Close
Exit Sub
errHandling:
MsgBox Err.Description
End Sub
Screenshot of VBA editor with Debug.Print strSQL
Debug.Print strSQL
statement after you've constructed your SQL string, then copy it from the Immediate Window ([Crtl-G] in the VBA editor) and update your question (click the "edit" link, above) to show us the SQL you are actually trying to execute. – Gord ThompsonCommand8_Click()
procedure with theDebug.Print strSQL
statement in it. – Gord ThompsonCurrentDb.Execute
) causes an error that gets handled byerrHandling:
then theDebug.Print
will never get executed, will it? Move theDebug.Print
statement to immediately followstrSQL = "UPDATE ..."
. – Gord ThompsonUPDATE tblReserve SET TableNum = D-02, CustomerID = 3, ResDate = '12/23/2013', ResTime = '10:00:00 PM' WHERE TableNum =D-02
this is what appeared in my immediate window after inputting data onto my form. – nutellafella