Clone Code Complication

  • Thread starter Thread starter Sue Compelling
  • Start date Start date
S

Sue Compelling

Hi (Access 2007)

I have the following code which works perfectly well for me on one form,
though when I've tried to replicate it on another form I get a run time error
3077 - Syntax error (missing operator) in expression .... I hope you can help
(they look exactly the same to me!) TIA.

WORKING CODE

Private Sub SearchCombo_AfterUpdate()
With Me.RecordsetClone
.FindFirst "JobID = " & SearchCombo
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
Me.Notes.SetFocus
End Sub


NON - WORKING CODE

Private Sub SearchCbo_AfterUpdate()
With Me.RecordsetClone
.FindFirst "NIRID = " & SearchCbo
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
Me.Customer.SetFocus
End Sub
 
Sue Compelling said:
Hi (Access 2007)

I have the following code which works perfectly well for me on one form,
though when I've tried to replicate it on another form I get a run time
error
3077 - Syntax error (missing operator) in expression .... I hope you can
help
(they look exactly the same to me!) TIA.

WORKING CODE

Private Sub SearchCombo_AfterUpdate()
With Me.RecordsetClone
.FindFirst "JobID = " & SearchCombo
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
Me.Notes.SetFocus
End Sub


NON - WORKING CODE

Private Sub SearchCbo_AfterUpdate()
With Me.RecordsetClone
.FindFirst "NIRID = " & SearchCbo
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
Me.Customer.SetFocus
End Sub

Well one thing jumps out straightaway. In the working version your combo is
called SearchCombo, whereas in the non-working code, it's called SearchCbo.
Perhaps you need to review your control names...
 
Hi Linq

It's definitely a number (NIRID is an AutoNumber).

The two forms are actually in the same database and store different record
types - hence the SearchCombo for one Form and the SerchCbo for the other
form.

Is that possibly what's making the difference?

ps - when I run my cursor over the .FindFirst "NIRID = " & SearchCbo in the
code it shows up the right data (ie - what's been selected in my SearchCbo)
 
Back
Top