Inserting not working

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

Guest

Hi there!

I seem to have a mental block for querying in code.

I'm trying to do the following:

Private Sub Command72_Click()
Dim mydb As DAO.Database
Set mydb = CurrentDb

mydb.Execute "Insert Into tblProjects (strProjectID, " _
& "strProjectName) values (" _
& strProjectID & ", " _
& strProjectName & " )"
End Sub

I get a Run Time error 3075

Syntax Error (missing operator) in query expression 'Database Test'

with 'Database Test' being the name of the project in my strProjectName field.

What am I doing wrong?
 
Hi Johnny

Any textual data in a SQL statement needs to be exclosed in either single or
double quotes. Try this:

mydb.Execute "Insert Into tblProjects (strProjectID, " _
& "strProjectName) values (" _
& strProjectID & ", """ _
& strProjectName & """ )"
 
Back
Top