Tuesday, November 25, 2008

Access: Using a combo or list box to navigate a form's record set

You'd expect access to have some of this functionality out of the box (.net does).
Not to worry, here's the code that seems to work:
Private Sub StdNoList_AfterUpdate()
Dim rs As DAO.Recordset
If Not IsNull(Me.StdNoList) Then
If Me.Dirty Then Me.Dirty = False
Set rs = Me.RecordsetClone
rs.FindFirst "pricing_id = " & Me.StdNoList & ""
If rs.NoMatch Then
MsgBox "Not Found"
Else
Me.Bookmark = rs.Bookmark
End If
End If
Set rs = Nothing
End Sub

No comments: