I have a contact database and I'm trying to create a regular add form so that the user can add new contacts. On the form, I have unbound text boxes for all the fields of the "contacts" table. I also have a buttom that the user has to push after he/she enters data so that the data could be added to the database.
Here is the code that I have on the "Onclick" event of the buttom:
Dim strSQL As String
strSQL = "INSERT INTO Contacts (LastName, FirstName) VALUES (" & Me.txtLname.Value & "," & Me.txtFname.Value & ");"
DoCmd.OpenQuery "strSQL", , acEdit
The error that I'm getting is the following:
Run-time error '7874
Microsoft Acces can't find the object strSQL
I have tested the SQL statement by displaying it in a textbox inside the form and it is correct.
Could anybody please help me with this?????
Here is the code that I have on the "Onclick" event of the buttom:
Dim strSQL As String
strSQL = "INSERT INTO Contacts (LastName, FirstName) VALUES (" & Me.txtLname.Value & "," & Me.txtFname.Value & ");"
DoCmd.OpenQuery "strSQL", , acEdit
The error that I'm getting is the following:
Run-time error '7874
Microsoft Acces can't find the object strSQL
I have tested the SQL statement by displaying it in a textbox inside the form and it is correct.
Could anybody please help me with this?????