SQL in vba issue

S

SirPoonga

I created a query using the query builder. I took the SQL of it and
put it into VBA code. I replaced one of the WHERE clause fields with a
variable. Here's teh SQL


sqlcmd = "SELECT [01_BOM_Record].[ID_ITEM_PAR],
[ITMMAS_BASE].[ID_ITEM], [ITMMAS_BASE].[DESCR_1] " & _
"FROM [01_BOM_Record] INNER JOIN [ITMMAS_BASE] ON
[01_BOM_Record].[ID_ITEM_COMP] = [ITMMAS_BASE].[ID_ITEM] " & _
"WHERE [01_BOM_Record].[ID_ITEM_PAR]=""" & mybucket & """ AND
[ITMMAS_BASE].[DESCR_1] Like ""*MOLDBOARD*"""

rs2.Open sqlcmd, CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
reccount = rs2.RecordCount



If I put a breakpoint as the rs2.open line and in the intermediate
window do a "print sqlcmd" I get a valid sql string. I take that
string and put it in the query builder. It runs fine, it returns the
two records for that part. But in code it returns 0 records. Any
ideas?
 
S

SirPoonga

I figured it out. It's ADO. It expects standard SQL which uses % as
the wildcard.
 

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