Select item in list box, display form

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

Guest

Help please, and thank you.

I have a listbox on a form based on a query. I want to double click on an
item and display results on another form. I have tried a few things and it
doesn't work.

Everything is based on an autonumber key field. How can this be done?
 
Hi Lin,

if your listbox is called lstContacts

then lstContacts.column(0) gives you the value of the first column of the
selected item.

for completeness I use

on the double click event

if not isnull(lstContacts.column(0)) then
form_myNewForm.Recordsource = "Select * from MyTable where myID=" &
lstContacts.Column(0)
form_myNewForm.Refresh
end if

Hope it helps.
 
Hi Alex thanks for reply...still not working

This is what I have

If Not IsNull(lstResults.Column(0)) Then
frmFSMain.RecordSource = "Select * from tblFSMain where FSFileID=" &
lstResults.Column(0)
frmFSMain.Refresh
End If

What did I do wrong

Sorry to be such a bother ....and thanks again
 
Hi Lin,

what columns are in use in the listbox, for the below example to work, the
FSFileID column on the listbox has to be the first column, if you don't want
to show it make the 'column widths' property something like '0cm;3cm'

Hope it helps
 

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

Back
Top