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!

Open form based on selection in a list box

Status
Not open for further replies.

jabrony76

Technical User
Apr 23, 2001
125
US
Hi all,
I have a dilemma which I have "rigged" to work but would like to do it the right way. I have search option on my main switchboard allowing to search by last name. When duplicates are found, a small form with a list box contained within that will show any duplicates will pop up. How can I set it so that when I double click an entry on the list box, it will open the main form with that record in focus.

I know it would be an event procedure "on double click" but do not know how to word the procedure to limit it to just one item in the list (i've tried and the main form just opens with the first record when i doubleclick). The items in the list are Last Name, First, DOB, and ID #. It would be easiest to use ID # b/c its the only unique item in the bunch.

I'm using Access 97 and i'm not that good w/ code so be gentle and spell it out as much as possible if you would :)

Thanks,
Andy
 
Hi Andy!

Here are codes example for solving your task.

If lstListBox bound column is same PersonID then:

Private Sub lstListBox_DblClick(Cancel As Integer)
dim SearchCriteria as string
dim frm as form
dim rst as recordset

SearchCriteria = me.lstListBox
docmd.openform "MainFormName"

set frm=forms("MainFormName")
set rst=frm.recordsetclone

'Use necessary identifiers for Date and Text type fields in the Find command
rst.findfirst "PersonID=" & SearchCriteria
if not rst.nomatch then
frm.bookmark=rst.bookmark
end if
rst.close
set rst=Nothing

end sub


Aivars
 
Forms!Mainform.findfirst "[ID]=" & me.ID

i hope it works
ide
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top