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

Visual Basic ClassicMicrosoft Access

Avatar of undefined
Last Comment
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

8/22/2022 - Mon
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

Try this ...

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

returns error 3077 missing operator the string now looks like "mvris code="1GIAO"" but you know that already!
ASKER CERTIFIED SOLUTION
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
PeterBaileyUk

.FindFirst "[mvris code] = " & Chr(34) &  RstCodestoProcess![MVRIS CODE] & Chr(34)

worked fine what was i doing wrong? i followed the microsoft help
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

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