Error 2495 - Open table

I am trying to add a record to an existing table 'ImpProjects' and receive the following error on DoCmd.OpenTable:
Action or method requires a table name argument - 2495.
Here is the code segment:
 sqlquery2 = "INSERT INTO ImpProjects (CustID, ProjType, CustProjLead,ProjLeadTitle,ProjLeadPhone,"
 sqlquery2 = sqlquery2 + " ProjLeadExt,OtherContacts,ServerOS,WorkStationOS,NumUsers,GoLiveDate) "
 sqlquery2 = sqlquery2 + " VALUES (txtCustID, lstProjType.value, txtCustProjLead, txtProjLeadTitle,"
 sqlquery2 = sqlquery2 + " txtProjLeadPhone, txtProjLeadExt, txtOthers, txtServerOS.value, txtWorkStationOS,"
 sqlquery2 = sqlquery2 + " txtNumUsers, txtGoLiveDate);"
 On Error GoTo ErrorHandler2
 DoCmd.OpenTable (ImpProjects)
 DoCmd.SetWarnings False
 DoCmd.RunSQL sqlquery2
 DoCmd.SetWarnings True
 DoCmd.Close acTable, ImpProjects, acSaveNo

I don't understand what the error requires me to do.
jberv534Asked:
Who is Participating?
 
BillystyxConnect With a Mentor Commented:
anddoes the error occur on this example? If so is it in the same place?
If so, then try replacing the brackets with "".
Also, on the close line, ImpProjects should be in quotes too.

Billystyx
0
 
BillystyxCommented:
you need to use ampersand(&) to concatenate strings in access, not (+)

Billystyx
0
 
jberv534Author Commented:
Billystyx, thanks for the input, but that is not the problem. I had already done that. It's blowing up on the open command not the run.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
BillystyxCommented:
have you tried:

DoCmd.OpenTable "ImpProjects"

billystyx
0
 
ArjiCommented:
Yes unless ImpProjects is a predefined string variable assigned to a table name(doesn't seem to be the case) you must use "ImpProjects".
0
 
jberv534Author Commented:
Here is a simpler example of the problem:
Dim sqlquery2 As String
 sqlquery2 = "INSERT INTO ImpProjects (CustID, ProjType) values ('11006','Extended');"
 On Error GoTo ErrorHandler2
 DoCmd.OpenTable (ImpProjects)
 DoCmd.SetWarnings False
 DoCmd.RunSQL sqlquery2
 DoCmd.SetWarnings True
 DoCmd.Close acTable, ImpProjects, acSaveNo

This runs from a button click on a form where the values have been entered in text boxes.

Hope this helps.
0
 
jberv534Author Commented:
Yep, it was the quotes on both instances of ImpProjects.

Thanks for the help.
0
 
BillystyxCommented:
no worries, glad to help:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.