Error 3061

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
 
D

Douglas J. Steele

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.
 
J

Joe

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?
 
D

Douglas J. Steele

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top