Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Access to send multiple receipents their excel reports

Status
Not open for further replies.

romeerome368

Programmer
Oct 12, 2010
35
US
Hello,

I have a database where I am creating a recordset to pull a list of receipents, and then generate an excel file with their own individual data as an attachment via VBA. The problem that I am running into is that I get an error message that states that it can't find my SQL statement.

Run-time error ‘3011’:

The Microsoft Jet database engine could not find the object ‘SELECT * FROM [tablename] WHERE [Fieldname] =’” & varFN & “’;”. Make sure the object exists and that you spell its name and the path name correctly.

strSQL = "SELECT * FROM [tablename] WHERE [FieldName] = '" & varFN & "';"

It seems as though my SQL statement is a valid one, but if I have forgotten something or my syntax is incorrect, please let me know.

Your assistance is greatly appreciated.

 



How about the rest of the code?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
have you tested it out on a real query?... step through the code, and when you get to the line AFTER this one, go to the immediate window, and type '?strSQL"... then copy (or cut, whichever) the sql, and take it to a query, putting in the SQL and run it.... if it doesn't work, you should be able to figure it out there.... then, once it is fixed, copy the SQL from the query, and paste it back into your code... then change the variable back to the coded variable.

That's what I do when I get an sql statement that doesn't work.

GComyn
[yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top