Error 3061

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

Hi All,

I know there are a number of posts out here regarding this error and I
have read a # of them but cannot seem to figure out why I am still
getting this message for my query. I have assigned a variable to for
my form parameter so am confused why it will not let me proceed.

Code below: (the variable "a" is a text value)


a = [Forms]![Contractor Conversion]![Project_Code]

Set rs = CurrentDb.OpenRecordset("SELECT [Contractor-Skill-
Project].Project_Code " & _
"FROM [Contractor-Skill-Project] " & _
"WHERE ([Contractor-Skill-Project].Project_Code)= " & a & ";")

Thanks
 
If Project_Code is a text field, you need quotes around the value you're
passing:

Set rs = CurrentDb.OpenRecordset("SELECT Project_Code " & _
"FROM [Contractor-Skill-Project] " & _
"WHERE (Project_Code= '" & a & "'")

Exagerated for clarity, that third line is

"WHERE (Project_Code= ' " & a & " ' ")

That assumes that there will never be apostrophes in the value contained in
a.
 
If Project_Code is a text field, you need quotes around the value you're
passing:

Set rs = CurrentDb.OpenRecordset("SELECT Project_Code " & _
"FROM [Contractor-Skill-Project] " & _
"WHERE (Project_Code= '" & a & "'")

Exagerated for clarity, that third line is

"WHERE (Project_Code= ' " & a & " ' ")

That assumes that there will never be apostrophes in the value contained in
a.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)


I know there are a number of posts out here regarding this error and I
have read a # of them but cannot seem to figure out why I am still
getting this message for my query. I have assigned a variable to for
my form parameter so am confused why it will not let me proceed.
Code below: (the variable "a" is a text value)
a = [Forms]![Contractor Conversion]![Project_Code]
Set rs = CurrentDb.OpenRecordset("SELECT [Contractor-Skill-
Project].Project_Code " & _
"FROM [Contractor-Skill-Project] " & _
"WHERE ([Contractor-Skill-Project].Project_Code)= " & a & ";")

Thanks much! That was the ticket.

Do you know any good online sources where a DAO newbie cando some
informative reading on this topic to learn how to work with and
manipulate datasets?
 
For this specific issue, it's the same as for DLookup, as Allen Browne
explains at http://www.allenbrowne.com/casu-07.html

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Thanks much! That was the ticket.

Do you know any good online sources where a DAO newbie cando some
informative reading on this topic to learn how to work with and
manipulate datasets?
If Project_Code is a text field, you need quotes around the value you're
passing:

Set rs = CurrentDb.OpenRecordset("SELECT Project_Code " & _
"FROM [Contractor-Skill-Project] " & _
"WHERE (Project_Code= '" & a & "'")

Exagerated for clarity, that third line is

"WHERE (Project_Code= ' " & a & " ' ")

That assumes that there will never be apostrophes in the value contained
in
a.
 
Back
Top