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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL query longer than 255 characters in vba?

Status
Not open for further replies.

davidd31415

Programmer
Jan 25, 2006
154
US
One last question for the day...

How might I perform an SQL query longer than 255 characters in VBA (i'm trying to do an INSERT that is much longer).

I've tried placing the query in separate strings and concatenating them together like this:

Call ErrorLogDB.Execute(sql1 & sql2 & sql3, dbFailOnError)

with no luck.

I'm think there might be a way to do this using a recordset object but i'm not sure on the exact code...

so far i have

with myRS
.AddNew
.Fields("fieldname") = fieldstring
.Update
End With
myRS.Close

If this will work, what do I need before it?

set myrs = db.... ?

Thanks,

David
 
Any error message when you try a long SQL string ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Syntax errors. Should the
.Execute(sql1 & sql2 & sql3, dbFailOnError)
command work when the 3 strings total more than 255 chars? If so I'l continue investigating the rest of my code/db.

Thanks.

 
A common mistake is to lack some spaces ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
From Access 2000 Help:

Query​
Number of enforced relationships - 32 per table minus the number of indexes that are on the table for fields or combinations of fields that are not involved in relationships
Number of tables in a query - 32
Number of fields in a recordset - 255
Recordset size -1 gigabyte
Sort limit - 255 characters in one or more fields
Number of levels of nested queries - 50
Number of characters in a cell in the query design grid - 1,024
Number of characters for a parameter in a parameter query - 255
Number of ANDs in a WHERE or HAVING clause - 99
Number of characters in an SQL statement approximately - 64,000

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
How are ya davidd31415 . . .

If you really want to nail this post the three sql strings . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top