Code for list box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Private Sub List25_Click()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[room]= '" & Me![List25] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

This is the code that I am using now to select records from a list box that
is pulling selected records from the main table. The problem I am having is I
can not figure out how to pull focus on [room] and an additional field
[building]. The above code works for selecting the records by [room] but I
can not make it change by the [building]
 
Try this code instead, it's simplier.

Private Sub ListGiveMeAnythingButTheDefaultName_Click()

Me.TableID.SetFocus
Docmd.FindRecord Me.ListGiveMeAnythingButTheDefaultName

End Sub

Put the TableID field in the Form Footer and make the
footer invisible.
 
I am already using code similar to the example you provided in a combo box to
search for records. The list box is displaying results from an embedded
query. The query example is below.

SELECT qry_Room_Openings.Room, qry_Room_Openings.Buildging,
qry_Room_Openings.SEX, qry_Room_Openings.ORG FROM qry_Room_Openings ORDER BY
qry_Room_Openings.Building, qry_Room_Openings.Room;

The other code that I am already using on the form (combo box) is also below

Sub Combo34_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[Room] = '" & Me![Combo34] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

Cheval said:
Try this code instead, it's simplier.

Private Sub ListGiveMeAnythingButTheDefaultName_Click()

Me.TableID.SetFocus
Docmd.FindRecord Me.ListGiveMeAnythingButTheDefaultName

End Sub

Put the TableID field in the Form Footer and make the
footer invisible.
-----Original Message-----
Private Sub List25_Click()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[room]= '" & Me![List25] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

This is the code that I am using now to select records from a list box that
is pulling selected records from the main table. The problem I am having is I
can not figure out how to pull focus on [room] and an additional field
[building]. The above code works for selecting the records by [room] but I
can not make it change by the [building]
.
 
Back
Top