Recordsets and Bookmarks

  • Thread starter Thread starter Darrin
  • Start date Start date
D

Darrin

Hello!

How do table relationships affect the creation of
recordsets and bookmarks. The code below works well if I
am trying only to see the information I enter into a combo
box in the immediate window. Can't get past no record
found and yet the value is there. Where have I gone wrong?

Private Sub Combo0_AfterUpdate()
' Find the record that matches the control.
If Not IsNull(Me.Combo0) Then
If Me.Dirty Then
Me.Dirty = False
End If
With Me.RecordsetClone
.FindFirst "[LRA#] = " & Me.Combo0
If .NoMatch Then
MsgBox "Not found."
Debug.Print Me.Combo0
Else
Me.Bookmark = .Bookmark
End If
End With
End If
End Sub

Thank you.
 
Darrin said:
How do table relationships affect the creation of
recordsets and bookmarks. The code below works well if I
am trying only to see the information I enter into a combo
box in the immediate window. Can't get past no record
found and yet the value is there. Where have I gone wrong?

Private Sub Combo0_AfterUpdate()
' Find the record that matches the control.
If Not IsNull(Me.Combo0) Then
If Me.Dirty Then
Me.Dirty = False
End If
With Me.RecordsetClone
.FindFirst "[LRA#] = " & Me.Combo0
If .NoMatch Then
MsgBox "Not found."
Debug.Print Me.Combo0
Else
Me.Bookmark = .Bookmark
End If
End With
End If
End Sub

That looks like very good code that should do what you want
as long as the [LRA#] field is a numeric type field and the
combo box's bound column has the proper value.

Just in case [LRA#] field is a Text field, it should be:

.FindFirst "[LRA#] = """ & Me.Combo0 & """"
 
Back
Top