Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select from List 1

Status
Not open for further replies.

Dustman

Programmer
May 7, 2001
320
US
I've got a search form with a listbox. The source for the listbox is a query (made on the fly as the user types the search string) and displays a list of matching results. When I double click on an item, I want it to open the form "PatientTable" and goto the record "PatientNum". The listbox is already bound to the patient number column and I can get it by using the list.value property.. I just can't remember how to tell access to open the PatientTable form and go to that record.

Thanks in advance!

-Dustin
 
It depends on how you want the form to open. Do you want it to open with all records available and with the correct patient showing, or do you want to have the form filtered and only showing that patient? Kathryn


 
I need it to open with all records available and the selected patient showing.

-Dustin
 
Dustin,

This is a good use of the OpenArgs propety of a form. When you use the DoCmd.OpenForm method, you can pass an argument to the newly opened form. Then in the Form_Open event, use that argument to go the record you want.

below is an example copied from the help files "OpenArgs Property Example" There are a few more examples you might want to check out in that topic.

Sub Form_Open(Cancel As Integer)
Dim strEmployeeName As String
' If OpenArgs property contains employee name, find corresponding
' employee record and display it on form. For example,
' if the OpenArgs property contains "Callahan", move to first
' "Callahan" record.
strEmployeeName = Forms!Employees.OpenArgs
If Len(strEmployeeName) > 0 Then
DoCmd.GoToControl "LastName"

DoCmd.FindRecord strEmployeeName, , True, , True, , True
End If
End Sub Kathryn


 
Works like a charm! Thats exactly the help I was needing.

Thanks!
-Dustin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top