Syntax error

  • Thread starter EMILYTAN via AccessMonster.com
  • Start date
E

EMILYTAN via AccessMonster.com

Below are my codes.
I want to check every row...if the quantity pending is <> 0 then end and it
will show the part number where the quantity pending <> 0....
But seems there is error in my loop statement...


Code:

mySQL = "SELECT WIPRawDetails.PartNumber, WIPRawDetails.W_QtyPending " &_

"FROM WIPRawDetails " & _
"WHERE WIPRawDetails.JobNumber= '" & Me.txtJobNumber & "' "
Debug.Print mySQL
myrecset.Open mySQL
Do Until myrecset.EOF
If W_QtyPending <> 0 Then
MsgBox "No completion"
End
Else
myrecset.MoveNext
End If
Loop
myrecset.Close
 
M

Marshall Barton

EMILYTAN said:
Below are my codes.
I want to check every row...if the quantity pending is <> 0 then end and it
will show the part number where the quantity pending <> 0....
But seems there is error in my loop statement...

Code:

mySQL = "SELECT WIPRawDetails.PartNumber, WIPRawDetails.W_QtyPending " &_

"FROM WIPRawDetails " & _
"WHERE WIPRawDetails.JobNumber= '" & Me.txtJobNumber & "' "
Debug.Print mySQL
myrecset.Open mySQL
Do Until myrecset.EOF
If W_QtyPending <> 0 Then
MsgBox "No completion"
End
Else
myrecset.MoveNext
End If
Loop
myrecset.Close


There are several errors in that code. If those are because
you retyped it in your post, please use Copy/Paste to save
us the time of debugging your typos.

Also, you need to tell us if you are using ADO or DAO,
because that code is the wrong syntax for DAO and I am not
sure if it's valid for ADO.

1) missing space before _
2) you are missing the recordset object with the field
reference in the loop.

OTOH, there is no need to use a loop at all. Use the SQL
statement's WHERE clause to filter the recordset to just
thise records with W_QtyPending <> 0

"WHERE WIPRawDetails.JobNumber= '" & Me.txtJobNumber _
& "' AND W_QtyPending <> 0"
 

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