after update code error

G

Guest

The following is my code. I placed >< around the one line that the debugger
points to. I get a Run-time error '3077': Syntax error (missing operator) in
expression.

I don't get it - I use this same exact code (with slightly different
parameters) for my supplier database and have no issues.

Anyone see what's wrong with this line in the code?

Thanks!


Private Sub cbCustomerName_AfterUpdate()
Dim strNewName As String

With Me.cbCustomerName

' Capture the customer NAME the user has selected or entered.
strNewName = .Value & vbNullString

If Len(strNewName) = 0 Then
' We've no idea what the user has in mind, so
' leave this alone.
Exit Sub
End If

' Is the user's entry an existing customer NAME?
If .ListIndex = -1 Then
' This is not an existing customer Name.
' If we aren't on a new record, undo this entry,
' go to a new record, and re-enter it there.
If Not Me.NewRecord Then
.Undo
Me.Undo
RunCommand acCmdRecordsGoToNew
.Value = strNewName
' Me.cbCustomerName = strNewName
End If
Else
' This is an existing customer NAME.
' Undo the entry on this record and
' go to the record that was entered.
.Undo
Me.Undo
Me.Recordset.FindFirst "txtCustomerName='" & strNewName & "'"<
End If

End With
End Sub
 
M

Marshall Barton

JohnLute said:
The following is my code. I placed >< around the one line that the debugger
points to. I get a Run-time error '3077': Syntax error (missing operator) in
expression.

I don't get it - I use this same exact code (with slightly different
parameters) for my supplier database and have no issues.

Anyone see what's wrong with this line in the code?


Private Sub cbCustomerName_AfterUpdate()
Dim strNewName As String

With Me.cbCustomerName

' Capture the customer NAME the user has selected or entered.
strNewName = .Value & vbNullString [snip]
Me.Recordset.FindFirst "txtCustomerName='" & strNewName & "'"<


The usual reason that kind of action gets that error is
when you run into a name like O'Hare. Try using double
quotes instead of apostrophes:

Me.Recordset.FindFirst "txtCustomerName=""" & strNewName &
""""
 
G

Guest

Thanks, Marshall! I should've known this because I recall having this problem
with another combo box.

Marshall Barton said:
JohnLute said:
The following is my code. I placed >< around the one line that the debugger
points to. I get a Run-time error '3077': Syntax error (missing operator) in
expression.

I don't get it - I use this same exact code (with slightly different
parameters) for my supplier database and have no issues.

Anyone see what's wrong with this line in the code?


Private Sub cbCustomerName_AfterUpdate()
Dim strNewName As String

With Me.cbCustomerName

' Capture the customer NAME the user has selected or entered.
strNewName = .Value & vbNullString [snip]
Me.Recordset.FindFirst "txtCustomerName='" & strNewName & "'"<


The usual reason that kind of action gets that error is
when you run into a name like O'Hare. Try using double
quotes instead of apostrophes:

Me.Recordset.FindFirst "txtCustomerName=""" & strNewName &
""""
 

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