Opening a form from a list box based on SQL query

T

tom

I have a list box on a form based on an SQL query.

The query relies on dates that are input into the form.

The list fields include the invoice number, Company
name, extension, etc. I want to double click on an
entry in the list and open another form using the
invoice number as criteria.

I have used various permutations of the following in
the where condition of the macro but I cannot get it
to work.

[number]=[Forms]![InvoiceForm]![MarginsNameOfListBOX]![Invoice number]
 
J

Jim Bunton

One solution is to use the double click event.
open the form in design mode
click on the list box
if the properties dialogue doesn't open
right click then click properties
click the event tab
click Dbl Click then the ... button
the class module window will open displaying

Private Sub YourListBoxName_DblClick(Cancel As Integer)


End Sub

this allows you to write a subroutine which runs when you double click the
list box
the subroutine will be 'something' like this
Private Sub YourListBoxName_DblClick(Cancel As Integer)

docmd.openform [parameters for which you are prompted one of which is
WHERE CONDITION]
'the where codition will be something like inviocenumber =
me.listboxname.column(0/1/2/. . . whichever)

End Sub
 

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

Top