• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 605
  • Last Modified:

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.
0
jberv534
Asked:
jberv534
  • 4
  • 3
1 Solution
 
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
 
BillystyxCommented:
have you tried:

DoCmd.OpenTable "ImpProjects"

billystyx
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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
 
BillystyxCommented:
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
 
jberv534Author Commented:
Yep, it was the quotes on both instances of ImpProjects.

Thanks for the help.
0
 
BillystyxCommented:
no worries, glad to help:)
0

Featured Post

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.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now