Need Statement Help?

  • Thread starter Thread starter Heather
  • Start date Start date
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)
 
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.
 
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)


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


.
 
Back
Top