syntaxt code error running sql query in a module

mazza

Registered User.
Local time
Today, 03:09
Joined
Feb 9, 2005
Messages
101
:confused: When I run this moduel I get a syntax error in string in query expression, 'queryincorrectprices.cat='false &;'
I also get an error on the group by expression. - expected: line number or label or end of statement

the end result is to display the query result on a message box, Hwr I would like to ignore or the message box to say no records if the query return no lines/data.
can somebody help me point in the right direction


Currrent module:

Dim ctl1 As Control
Dim cmd1 As Command
Dim rst1 As Recordset
Dim str1 As String

Set cmd1 = New ADODB.Command
With cmd1
.ActiveConnection = CurrentProject.Connection
.CommandText = "SELECT QryIncorrectprices.Dispref, " & _
"QryIncorrectprices.Sellprice, " & _
"QryIncorrectprices.cat " & _
"FROM QryIncorrectprices " & _
"WHERE QryIncorrectprices.cat = 'false & ;"
"GROUP BY QryIncorrectprices.Dispref, QryIncorrectprices.Sellprice, QryIncorrectprices.Sellprice;"
.CommandType = adCmdText
.Execute
End With
Set cmd1 = QryIncorrectprices
Set rst1 = New ADODB.Recordset
rst1.Open [QryIncorrectprices], , adOpenKeyset, adLockOptimistic
Do Until rst1.EOF
str1 = str1 & rst1.Fields(0) & ", " & rst1.Fields(1) & ", " & rst1.Fields(2)
str1 = str1 & vbCrLf
rst1.MoveNext
Loop
MsgBox str1, vbInformation, "SQS"
 
try
"WHERE QryIncorrectprices.cat = false " & _

Peter
 
mazza said:
Code:
Dim cmd1 As Command
Dim rst1 As Recordset

Another thing: be explicit when declaring object variables.

Code:
Dim cmd1 As ADODB.Command
Dim rst1 As ADODB.Recordset
 

Users who are viewing this thread

Back
Top Bottom