listbox help!!

M

mike

Hi All,

I created a list box and I created a query in the row
source of the list box property. The list box retrieves
the records and displays the records in list base on the
query. I try programming the listbox to display the record
in another form base on the selection I made in the list
box. Any suggestions on how to program the list box to
show the records in another form so when the form displays
it should have the record shown??

Thanks for the help...

mike
 
M

Mike M.T.

1. Let's say that:
- you have two tables in your database: Customers and Orders.
- those tables are related on the CustomerID field.
- the List Box contains two columns:
- CustomerID (hidden)
- CustomerName (displayed)
- you want to display in a separate form the dates when the customer
selected in the List Box placed an order.

2. Create a Text Box named QueryCriteria on the form containing the List Box
and add the following code in the form module:

Private Sub ListBoxName_Click()
Me.QueryCriteria = Me.ListBoxName.Column(0)
End Sub

Note: replace ListBoxName with the name of your List Box.

3. Create a query to retrieve the OrderDate and CustomerID fields from the
Orders table. Add the following criteria to the CustomerID field.

Forms!YourFormName!QueryCriteria

Note: replace YourFormName with the name of the form containing the List
Box.

4. Create a form based on the query created in step 3.

5. Add a Command Button to the form containing the List Box to open the form
created in step 4.
 

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