Listbox AfterUpdate

J

JamesJ

I have a form with a listbbx and both are based on the same table.
I want the listbox and form to display the same row when I make a
selection in the listbox.
I'm populating the listbox with dvd titles and have placed the movie
description on the form. When selecting a title in the listbox I want
the pertinent description for that title to display in the description.
I found some old code and it works but I'm sure there's a better way.

Me.RecordsetClone.FindFirst ("DvdMovieID=" & Me!lstTitle)
Me.Bookmark = Me.RecordsetClone.Bookmark

Sny help will be appreciated,
James
 
J

Jeanette Cunningham

James,
adding a couple of lines to cover for no match being found often fixes this
sort of problem with combos and listboxes
-----------------------------------
Dim rst as DAO.Recordset
If Not IsNull(Me.lstTitle) Then
Set rst = Me.RecordsetClone

rst.FindFirst "DvdMovieID=" & Me!lstTitle

If rst.NoMatch Then
Msgbox "Not found"
Else
Me.Bookmark = Rst.Bookmark
End If

Set rst = Nothing
-----------------------------------

Note: if DvdMovieID is a text field you need to use
rst.FindFirst "DvdMovieID=""" & Me.lstTitle & """"
Note: that is 3 double quotes around Me.lstTitle and an extra one at the
end.


Jeanette Cunningham
 

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