Link to home
Start Free TrialLog in
Avatar of tupac1979
tupac1979

asked on

Run time error 3077

I am receiving a run time error '3077' Syntax error (missing operator) in expression on the following line:
 -   rec.FindFirst "FileID = " & rs("FileID").Value & "ClassID = " & classnum
the code is provided below:

If intResult = vbYes Then
 StrSQL = "SELECT FileID, OccupationID FROM EMPLOYEE WHERE TERMINATED = 0"
 StrSQL1 = "SELECT * FROM Employee_Train"
 
 Set db = CurrentDb()
 Set rs = db.OpenRecordset(StrSQL, dbOpenSnapshot, dbReadOnly)
 Set rec = db.OpenRecordset(StrSQL1, dbOpenSnapshot)
 
 Do Until rec.EOF
  rec.FindFirst "FileID = " & rs("FileID").Value & "ClassID = " & classnum
   If rec.NoMatch = False Then
    With rec
     .AddNew
      .Fields("FileID") = rs("FileID").Value
      .Fields("OccupationID") = rs("OccupationID").Value
      .Fields("ClassID") = "& classnum &"
      .Fields("ClassTaken") = False
      .Fields("Date_Ent") = Format(CDate(todaydat), "dd/mm/yyyy")
      .Update
     End With
     rec.MoveNext
     Else
     rec.MoveNext
     End If
     Loop
     rs.Close
     rec.Close
     db.Close
     Set db = Nothing
     End If
     End If
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of manthanein
manthanein

if my presumption is correct, cause I never use Findfirst

you should change
"FileID = " & rs("FileID").Value & "ClassID = " & classnum

to
"FileID = " & rs("FileID").Value & " and ClassID = " & classnum
Avatar of tupac1979

ASKER

Thanks Jim that worked