Link to home
Start Free TrialLog in
Avatar of PeterBaileyUk
PeterBaileyUk

asked on

.findfirst syntax error

I was hoping to loop around rstcodestoprocess grabbing the [mvris code] each time and then updating a field in the bestmatch table via rstbestmatch.

However the findfirst wont work. at the moment it returns (strcriteria) "mvris code=1GIAO" I have tried "[mvris code]=1GIAO" that fails too.

help would be appreciated
Private Sub BtnUpdateBestmatch_Click()

Dim db As Database
Dim rstBestMatch As DAO.Recordset
Dim RstCodestoProcess As DAO.Recordset
Dim strCriteria As String


Set db = CurrentDb
Set rstBestMatch = db.OpenRecordset("BestMatch", dbOpenSnapshot)
Set RstCodestoProcess = db.OpenRecordset("QryTotalCWCodestoProcess", dbOpenSnapshot)
With RstCodestoProcess

Do While Not .EOF
.MoveFirst
    strCriteria = "mvris code=" & RstCodestoProcess![MVRIS CODE]
    
    With rstBestMatch
    
        .FindFirst (strCriteria)
        .Edit
        .Fields("ForDeletionafterDataUpdate").Value = True
        .Update
    End With


Loop


End With


End Sub

Open in new window

Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Try this ...

strCriteria = "mvris code=" & Chr(34) &  RstCodestoProcess![MVRIS CODE] & Chr(34)
Avatar of PeterBaileyUk
PeterBaileyUk

ASKER

returns error 3077 missing operator the string now looks like "mvris code="1GIAO"" but you know that already!
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
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
.FindFirst "[mvris code] = " & Chr(34) &  RstCodestoProcess![MVRIS CODE] & Chr(34)

worked fine what was i doing wrong? i followed the microsoft help
Well, my first post should ... have worked ... really no difference that I can see.

The main issue was ... you have to surround String criteria in double quotes, which is what Chr(34) is ... a double quote.  Just like Date criteria have to be surrounded with pound signs (#).  Numeric criteria requires nothing.

mx