Display record from list

M

Michael Nol

Hi

I need to be able to display a record which is based on a selected line of a
list box.

The list box is unbound and populated from another list box using

Private Sub List0_AfterUpdate()
Me![List2].RowSource = "SELECT qry_Plant.[Product Name],
qry_Plant.PlantTypeId, qry_Plant.PlantID FROM qry_Plant WHERE
qry_Plant.PlantTypeID = '" & Me![List0] & "'"
End Sub

I then have an onclick event to search for the relevant record

Private Sub List2_Click()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[PlantID] = '" & Me![List2] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

It does not seem to be finding any records

Could someone help with this??


Thanks

Michael
 
M

Marshall Barton

Michael said:
I need to be able to display a record which is based on a selected line of a
list box.

The list box is unbound and populated from another list box using

Private Sub List0_AfterUpdate()
Me![List2].RowSource = "SELECT qry_Plant.[Product Name],
qry_Plant.PlantTypeId, qry_Plant.PlantID FROM qry_Plant WHERE
qry_Plant.PlantTypeID = '" & Me![List0] & "'"
End Sub

I then have an onclick event to search for the relevant record

Private Sub List2_Click()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[PlantID] = '" & Me![List2] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

It does not seem to be finding any records


Are you sure the list box is set for single select?

OTOH, maybe you should be using Me.RecordsetClone instead of
Me.Recordset.Clone
 
M

Michael Nol

Hi Marshall

Yes I the list box is set for single select only and I have taken the '.'
out of Me.Recordset.Clone with no luck...

any other ideas

Michael

Marshall Barton said:
Michael said:
I need to be able to display a record which is based on a selected line of a
list box.

The list box is unbound and populated from another list box using

Private Sub List0_AfterUpdate()
Me![List2].RowSource = "SELECT qry_Plant.[Product Name],
qry_Plant.PlantTypeId, qry_Plant.PlantID FROM qry_Plant WHERE
qry_Plant.PlantTypeID = '" & Me![List0] & "'"
End Sub

I then have an onclick event to search for the relevant record

Private Sub List2_Click()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[PlantID] = '" & Me![List2] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

It does not seem to be finding any records


Are you sure the list box is set for single select?

OTOH, maybe you should be using Me.RecordsetClone instead of
Me.Recordset.Clone
 

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

Similar Threads

Copy Record Button Function 1
Multiple Criteria 4
Textbox Filter 4
Error 2147352567 2
Error 2237 8
Searching 3
RunTime Error 3070 11
VBA for NotInList return to old record or BeforeUpdate value 2

Top