Discussion Locked

dao.recordset.FindFirst

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a syntex error(missing operator) in expression for the FindFirst statement in following code which run in access form vba routine

Option Explicit

Private Sub Form_Load()
On Error GoTo errAddNode

Const strTableQueryName = "Quantity"

Dim db As DAO.Database, rst As DAO.Recordset
Dim strParentField As String
Dim strCriteria As String

Set db = CurrentDb
Set rst = db.OpenRecordset(strTableQueryName, dbOpenDynaset, dbReadOnly)
strParentField = "NEXT ASSEMBLY"

strCriteria = BuildCriteria(strParentField, _
rst.Fields(strParentField).Type, "=" & "21120 - 1")

rst.FindFirst (strCriteria) 'syntex error (missing operator) in expression.

exitAddNode: Exit Sub

errAddNode:
MsgBox Err.Description, vbCritical, "Error:"
Resume exitAddNode
End Sub

Help please!!!!

1 reply

by stephen.kendall

It looks like the the field name you store in strParentField contains a space, which will cause an error. Try adding square brackets around the field name like this:

strParentField = "[NEXT ASSEMBLY]"

This discussion is closed to new replies.