Solved Run-time error '3077' Syntax error (missing operator) in expression.

5hadow

Member
Local time
Today, 16:09
Joined
Apr 26, 2021
Messages
89
I have Run-time error '3077' Syntax error (missing operator) in expression error come up when trying to .findFirst in my recordset.

Code:
 'Criteria'
 strCrit = "pkEventID = " & DMax("pkEventID", "tblEvents", "[fkAircraftID] = " & Me.cboTail & " AND [fldDateEnd] is null")

'Part of code'
                .FindFirst strCrit
                If .NoMatch Then
                    Resume Next
                End If

It works ok when there are matching records. However, when it's a new record I get the error. I expect it not to find a record, but I don't want the error.

Does anyone know what's wrong with syntax? I also tried this:
strCrit = "pkEventID = " & DMax("pkEventID", "tblEvents", "[fkAircraftID] = " & Me.cboTail & " AND [fldDateEnd] is null") & ""
 
maybe put Nz():

strCrit = "pkEventID = " & Nz(DMax("pkEventID", "tblEvents", "[fkAircraftID] = " & Nz(Me.cboTail, 0) & " AND [fldDateEnd] is null"), 0) & ""
 
Add a debug.print strcrit to see what it resolves to.

is [fkAircraftID] numeric?
 
maybe put Nz():

strCrit = "pkEventID = " & Nz(DMax("pkEventID", "tblEvents", "[fkAircraftID] = " & Nz(Me.cboTail, 0) & " AND [fldDateEnd] is null"), 0) & ""
That works, thanks!
 

Users who are viewing this thread

Back
Top Bottom