D
Damien
The list of all records you saw was probably a ListBox.
You can populate it using a query or table and use it's
double-click event to open a form based on the record that
has been clicked:
eg
Private Sub List1_DblClick(Cancel As Integer)
'Open the detail form based on the value that has been
double-clicked on the main form ListBox List1
DoCmd.OpenForm "frm_detail", acNormal, , "staff_id = "
& Me.List1
'Use quotes for strings eg
DoCmd.OpenForm "frm_detail", acNormal, , "staff_id = '" &
Me.List1 & "'"
End Sub
You can also set criteria in your query based on values on
your form. For example if form frm_main has a ComboBox
cmbTitle, you can set crtieria in your query like:
SELECT * FROM staff
WHERE staff_title = [Forms]![frm_main]![cmbTitle]
OR surname = [Forms]![frm_main]![txtSurname]
If you then set the RowSource of your ListBox to the above
query, and Requery it using a CommandButton:
PrivateSub cmdSearch_Click()
Me.List1.Requery
End Sub
you should see the records in your Listbox change
according to the criteria you have entered.
It starts to get a bit more complicated from there, but
hopefully you get the idea !
Let me know how you get on.
Damien
You can populate it using a query or table and use it's
double-click event to open a form based on the record that
has been clicked:
eg
Private Sub List1_DblClick(Cancel As Integer)
'Open the detail form based on the value that has been
double-clicked on the main form ListBox List1
DoCmd.OpenForm "frm_detail", acNormal, , "staff_id = "
& Me.List1
'Use quotes for strings eg
DoCmd.OpenForm "frm_detail", acNormal, , "staff_id = '" &
Me.List1 & "'"
End Sub
You can also set criteria in your query based on values on
your form. For example if form frm_main has a ComboBox
cmbTitle, you can set crtieria in your query like:
SELECT * FROM staff
WHERE staff_title = [Forms]![frm_main]![cmbTitle]
OR surname = [Forms]![frm_main]![txtSurname]
If you then set the RowSource of your ListBox to the above
query, and Requery it using a CommandButton:
PrivateSub cmdSearch_Click()
Me.List1.Requery
End Sub
you should see the records in your Listbox change
according to the criteria you have entered.
It starts to get a bit more complicated from there, but
hopefully you get the idea !
Let me know how you get on.
Damien