Return Listbox results on double click

testdba

Registered User.
Local time
Today, 07:48
Joined
Dec 16, 2004
Messages
26
This is probably failry simple if you know what you're doing, but I don't know what I'm doing....

I have a form (Purchase Orders) and on that form there is a search button to allow the user to search the customers table by customer name. When the user clicks the search button a search form opens and the search results (customer number, first name, last name) populate a list box named "lstCustInfo". How can I set the list box double click event to return the customer number, first name and last name to the Purchase Orders form? To make it even more complex I would like to return the data in two fields: customer number and LastName, FirstName. The problem with returning the results in two fields though is that I need to be able to break it into three to save it in the customers table because the table has a place for Customer Number, First Name and Last name.

Does anyone have any suggestions? Is there a better way to do this than returning 2 fields and having to break it back into 3 to store?
 
The search form should only return the customer number. Using that number the PO form should know how to get the names all by itself.
 
I guess the trouble I'm having is getting the search form to return the value. I have attached an example. I just need help getting the value from the listbox to the purchase orders form. :)
 

Attachments

testdba said:
I guess the trouble I'm having is getting the search form to return the value. I have attached an example. I just need help getting the value from the listbox to the purchase orders form. :)

I don't see why you have duplicated data in the second table.

Have a look at this reworking. You had a field you don't even need, some weird setup in your relationships, and I can see lots of opportunities for new tables.
 

Attachments

List Box Results

The code below should give you what you need. Note that I have added 3 additional fields for simplicity, remove them once you are done looking through the code. The information is now written in to the original fields you had. I have also attached a working database for you to use.

Private Sub lstCustInfo_DblClick(Cancel As Integer)
'Writes information on to your original fields
'The Customer name is written as Last Name, First Name
Forms!frmPurchaseOrders.CustomerID = Me.lstCustInfo.Column(0)
Forms!frmPurchaseOrders.Customer = Me.lstCustInfo.Column(2) & ", " & Me.lstCustInfo.Column(1)


'Writes the information on the fields added by me. From here you can see
'How you can select the information on the list box
Forms!frmPurchaseOrders.txtCustomer = Me.lstCustInfo.Column(0)
Forms!frmPurchaseOrders.txtFirst = Me.lstCustInfo.Column(1)
Forms!frmPurchaseOrders.txtLast = Me.lstCustInfo.Column(2)
End Sub
 

Attachments

Cascade List boxes

I have the coding for 2 list boxes CD Group and CD Name however I can't get the list boxes populated so when I click on CD Group it only displays the records from the CD NAme.

Can you help me out on this so I can email you the data base?
mikevds@optonline.net

Thanjs,

Mike Van Der Stad
 
Thanks.

godofhell said:
The code below should give you what you need. Note that I have added 3 additional fields for simplicity, remove them once you are done looking through the code.

Thanks for the help. Using your example I was able to get what I need. :)
 

Users who are viewing this thread

Back
Top Bottom