R
requeth
Hello,
I'm receiving an error: "Run-time error '3061': Too few parameters.
Expected 1." from the following code. It works fine if I cut it off at
just the randnumber variable, but for data integrity I need to make
sure two fields match before I pull the Key field and save it. Am I
able to use double criteria in this sense? Or do I need to pull all
data with randnumber and save it to a temp table, and then query the
temp table with the second? It's longer but could be done if I have
to.
Thanks!
Set db = CurrentDb
'MsgBox keyvar
strSQL = "SELECT QCMS_PRIMARY.Key FROM QCMS_PRIMARY WHERE
QCMS_PRIMARY.RANDNUM = " & randnumber & " AND QCMS_PRIMARY.QA_SPCT_ID
= " & smoke & ""
'strSQL = "SELECT * FROM QCMS_PRIMARY WHERE RANDNUM = " &
randnumber
Set rs = db.OpenRecordset(strSQL)
'Exit if recordset has no records
If rs.EOF And rs.BOF Then
MsgBox "An error occured while saving. Please verify all fields
are filled out and try again. If the problem continues notify the
Process Team leader."
Exit Sub
End If
rs.MoveFirst
Do Until rs.EOF
strValue1 = rs!Key
'Do something with those values...
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
I'm receiving an error: "Run-time error '3061': Too few parameters.
Expected 1." from the following code. It works fine if I cut it off at
just the randnumber variable, but for data integrity I need to make
sure two fields match before I pull the Key field and save it. Am I
able to use double criteria in this sense? Or do I need to pull all
data with randnumber and save it to a temp table, and then query the
temp table with the second? It's longer but could be done if I have
to.
Thanks!
Set db = CurrentDb
'MsgBox keyvar
strSQL = "SELECT QCMS_PRIMARY.Key FROM QCMS_PRIMARY WHERE
QCMS_PRIMARY.RANDNUM = " & randnumber & " AND QCMS_PRIMARY.QA_SPCT_ID
= " & smoke & ""
'strSQL = "SELECT * FROM QCMS_PRIMARY WHERE RANDNUM = " &
randnumber
Set rs = db.OpenRecordset(strSQL)
'Exit if recordset has no records
If rs.EOF And rs.BOF Then
MsgBox "An error occured while saving. Please verify all fields
are filled out and try again. If the problem continues notify the
Process Team leader."
Exit Sub
End If
rs.MoveFirst
Do Until rs.EOF
strValue1 = rs!Key
'Do something with those values...
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing