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

VBA SQL

Status
Not open for further replies.

mikeba1

Programmer
Jan 2, 2005
235
GB
Can anyone help with the following code.
I get runtime error 3061
Too few parameters, expected 5


Thanks



Private Sub Command27_Click()
Dim db As Database
Dim rst As Recordset
Dim sqlstr As String
Dim ren
sqlstr = "SELECT qryacctsinterface1.SLIPrefix," qryacctsinterface1.CurrencYCode,"
sqlstr = sqlstr & " qryacctsinterface1.SLIInvoiceGoodsValueLC," qryacctsinterface1.SLIInvoiceVATValueLC,"
sqlstr = sqlstr & " qryacctsinterface1.GoodsSTG , "qryacctsinterface1.VATstg "
sqlstr = sqlstr & " From qryacctsinterface1 "
sqlstr = sqlstr & " WHERE ((qryacctsinterface1.SLIPrefix)='re');"
MsgBox (sqlstr)
Set db = CurrentDb()
Set rst = db.OpenRecordset(sqlstr, dbOpenDynaset)
With rst
MsgBox (.RecordCount)
If .RecordCount > 0 Then
' records found
.MoveFirst
' loop tru
Do Until .EOF
ren = ren + 1
.MoveNext
Loop
End If
.Close
End With
End Sub
 


hi,

You had some extraneous QUOTES...
Code:
sqlstr = "SELECT q.SLIPrefix"
sqlstr = sqlstr & ", q.CurrencYCode"
sqlstr = sqlstr & ", q.SLIInvoiceGoodsValueLC"
sqlstr = sqlstr & ", q.SLIInvoiceVATValueLC"
sqlstr = sqlstr & ", q.GoodsSTG "
sqlstr = sqlstr & ", q.VATstg "
sqlstr = sqlstr & " From qryacctsinterface1 q"
sqlstr = sqlstr & " WHERE ((q.SLIPrefix)='re');"

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks Skip, but I copied your answer and got the same error ??
 
What I did was create the query, then look at the SQL behind it, so I dont know which fields are wrong

 
What is the SQL code of qryacctsinterface1 ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top