Need Statement Help?

H

Heather

Errors out!
Not sure what this was suppose to do think wanted to
return all Labels.

How can I fix this?

sql = "insert into tmp_contact (CONTACT_ID,LABEL) " & _
"select CONTACT_ID, LABEL FROM dbo_CONTACT_LABELS
WHERE LABEL='" & lbl & "'"
CurrentDb.Execute (sql)
 
W

Wayne Morgan

2 possible problems:

1) Label is a reserved word so try enclosing it in brackets (i.e. [Label])

2) Try removing the parenthesis from the CurrentDb.Execute line

CurrentDb.Execute SQL

Also, I would probably change the variable SQL to strSQL. SQL is a property
of queries and as in #1, may cause a problem.
 
H

heather

What is happing is that in the label field " are being put
in as criteria how do I stop that? There must be something
wrong with the staement I can not see it.


-----Original Message-----
2 possible problems:

1) Label is a reserved word so try enclosing it in brackets (i.e. [Label])

2) Try removing the parenthesis from the CurrentDb.Execute line

CurrentDb.Execute SQL

Also, I would probably change the variable SQL to strSQL. SQL is a property
of queries and as in #1, may cause a problem.

--
Wayne Morgan
Microsoft Access MVP


Errors out!
Not sure what this was suppose to do think wanted to
return all Labels.

How can I fix this?

sql = "insert into tmp_contact (CONTACT_ID,LABEL) " & _
"select CONTACT_ID, LABEL FROM dbo_CONTACT_LABELS
WHERE LABEL='" & lbl & "'"
CurrentDb.Execute (sql)


.
 
W

Wayne Morgan

I'm guessing that what is being put in is '' not " (i.e. two single quotes,
not a single double quote). This would happen if lbl was a zero length
string or Null and would be correct for what your statement says. What are
you wanting if lbl is Null or a zero length string?

--
Wayne Morgan
Microsoft Access MVP


heather said:
What is happing is that in the label field " are being put
in as criteria how do I stop that? There must be something
wrong with the staement I can not see it.


-----Original Message-----
2 possible problems:

1) Label is a reserved word so try enclosing it in brackets (i.e. [Label])

2) Try removing the parenthesis from the CurrentDb.Execute line

CurrentDb.Execute SQL

Also, I would probably change the variable SQL to strSQL. SQL is a property
of queries and as in #1, may cause a problem.

--
Wayne Morgan
Microsoft Access MVP


Errors out!
Not sure what this was suppose to do think wanted to
return all Labels.

How can I fix this?

sql = "insert into tmp_contact (CONTACT_ID,LABEL) " & _
"select CONTACT_ID, LABEL FROM dbo_CONTACT_LABELS
WHERE LABEL='" & lbl & "'"
CurrentDb.Execute (sql)


.
 

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