Syntax (Missing Operator) Error

P

Pamela

Running NotInList event on cboAdjusterID to open pop up frmAdjuster and then
add the new item. Upon closing frmAdjuster, get "missing operator" error
that when debugged highlights the .FindFirst "[AdjusterID] ... line. The
combo is bound by the ID field which is a number but the box displays the
full name, which concatenates the FirstName and LastName fields, for example,
"John Doe." This then would be the same format that the user would type into
it, but then would have to separate upon entry into the frmAdjuster.
Would someone please help me find the problem with this .FindFirst procedure?
Thanks!!

Here is the code:
Private Sub cboAdjusterID_NotInList(NewData As String, Response As Integer)
If MsgBox(NewData & " is not in the list." & vbCrLf & "Would you like to add
" & NewData & "?", vbQuestion + _
vbYesNo + vbDefaultButton2, "Not Found") = vbYes Then

Me.cboAdjusterID.Undo

DoCmd.OpenForm "frmAdjuster", , , , acFormAdd, acDialog,
Me.InsuranceCoID

Response = acDataErrAdded
Me.Requery
With Me.RecordsetClone

.FindFirst "[AdjusterID] = " & NewData
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
Else

Me.cboAdjusterID.Undo

Response = acDataErrContinue
End If
End Sub
 
J

John W. Vinson/MVP

Running NotInList event on cboAdjusterID to open pop up frmAdjuster and then
add the new item. Upon closing frmAdjuster, get "missing operator" error
that when debugged highlights the .FindFirst "[AdjusterID] ... line.

You'll get this error if NewData is null. If you step through the
code, what's the value of NewData at this point?
 
P

Pamela

I've been testing how it works by inputting sample names and really trying to
run it. I fill out the form, knowingly type in a name that is not in the
list to get the code to run. For instance, I type in John Doe, and it seems
to work -- the NotInList Msgbox opens and I chose to Add the new item, the
correct form, frmAdjuster, opens I enter the new adjuster info, exit the form
and when the form closes, I see the error. (Perhaps the error has been there
all along but the new form is coded to pop up over it). For instance I just
used the name "Alicia Campos." If I hit End on the error, it takes me back
to my orig. form but the AdjusterID field is blank and there are no drop-down
options in the box until I reselect the combo box from which it is filtered.
Once I do that, the name Alicia Campos did appear in the box. Thank you so
much, I know I might be a little slow on this stuff, I'm still learning, but
I have been working on this pretty much all day and it can get quite
frustrating!! : )

Pamela

John W. Vinson/MVP said:
Running NotInList event on cboAdjusterID to open pop up frmAdjuster and then
add the new item. Upon closing frmAdjuster, get "missing operator" error
that when debugged highlights the .FindFirst "[AdjusterID] ... line.

You'll get this error if NewData is null. If you step through the
code, what's the value of NewData at this point?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top