Synch Listbox and Form

  • Thread starter Thread starter JamesJ
  • Start date Start date
J

JamesJ

I'm trying to use an InputBox function to find text in a
listbox and a form which are based on the same data
The code finds the string in the form but I can't figure
out how to have the listbox go the found text. For
instance, I'm trying to find a movie title in my dvd
library table and have the form and the listbox on
the same row by synchronizing the listbox and the
form after the code finds the text in the form.
I hope I explained this ok, it's early.

Thanks,
James
 
JamesJ said:
I'm trying to use an InputBox function to find text in a
listbox and a form which are based on the same data
The code finds the string in the form but I can't figure
out how to have the listbox go the found text. For
instance, I'm trying to find a movie title in my dvd
library table and have the form and the listbox on
the same row by synchronizing the listbox and the
form after the code finds the text in the form.


Just assign the list box's value from the form's field that
corresponds to the list box's BoundColumn.
 
I'm not making any headway.
lstDvd is the list box and DvdMovieID is the boundcolumn
Here's the code:

Private Sub cmdFind_Click()

Dim rst As DAO.Recordset
Dim strCriteria As String

strCriteria = "[DvdMovieTitle] Like '*" & InputBox("Enter the " _
& "first few letters of the Movie Title") & "*'"

Set rst = Me.RecordsetClone

rst.FindFirst strCriteria

If rst.NoMatch Then
MsgBox "No entry found.", vbInformation
Else
Me.Bookmark = rst.Bookmark
Me!lstDvd.DvdMovieID = Me!DvdMovieID 'I'm getting
'object doesn't support this property or method'
End If

Set rst = Nothing


End Sub
 
I don't know what you thought a field name would do for the
list box's Value. All you need is:

Me!lstDvd = Me!DvdMovieID
--
Marsh
MVP [MS Access]

I'm not making any headway.
lstDvd is the list box and DvdMovieID is the boundcolumn
Here's the code:

Private Sub cmdFind_Click()

Dim rst As DAO.Recordset
Dim strCriteria As String

strCriteria = "[DvdMovieTitle] Like '*" & InputBox("Enter the " _
& "first few letters of the Movie Title") & "*'"

Set rst = Me.RecordsetClone

rst.FindFirst strCriteria

If rst.NoMatch Then
MsgBox "No entry found.", vbInformation
Else
Me.Bookmark = rst.Bookmark
Me!lstDvd.DvdMovieID = Me!DvdMovieID 'I'm getting
'object doesn't support this property or method'
End If

Set rst = Nothing

End Sub

Just assign the list box's value from the form's field that
corresponds to the list box's BoundColumn.
 
I don't know either, but this works fine now.

Thanks,
James

Marshall Barton said:
I don't know what you thought a field name would do for the
list box's Value. All you need is:

Me!lstDvd = Me!DvdMovieID
--
Marsh
MVP [MS Access]

I'm not making any headway.
lstDvd is the list box and DvdMovieID is the boundcolumn
Here's the code:

Private Sub cmdFind_Click()

Dim rst As DAO.Recordset
Dim strCriteria As String

strCriteria = "[DvdMovieTitle] Like '*" & InputBox("Enter the " _
& "first few letters of the Movie Title") & "*'"

Set rst = Me.RecordsetClone

rst.FindFirst strCriteria

If rst.NoMatch Then
MsgBox "No entry found.", vbInformation
Else
Me.Bookmark = rst.Bookmark
Me!lstDvd.DvdMovieID = Me!DvdMovieID 'I'm getting
'object doesn't support this property or method'
End If

Set rst = Nothing

End Sub

JamesJ wrote:
I'm trying to use an InputBox function to find text in a
listbox and a form which are based on the same data
The code finds the string in the form but I can't figure
out how to have the listbox go the found text. For
instance, I'm trying to find a movie title in my dvd
library table and have the form and the listbox on
the same row by synchronizing the listbox and the
form after the code finds the text in the form.

"Marshall Barton" wrote
Just assign the list box's value from the form's field that
corresponds to the list box's BoundColumn.
 
Back
Top