Copying from a list box to a table on 'doubleclick' ??? (1 Viewer)

JustMaybe

Registered User.
Local time
Today, 11:32
Joined
Oct 18, 2002
Messages
134
Okay heres my problem!!! I have a form ‘selection’ on which I have a combo box, from which the user selects a category. This choice of category generates all the relevant products within this category to a list box.

I have an order form which includes a orders subform, this subform holds all the information of the products ordered for each particular record.

There are many products …too many for my previous drop down list..so I have a button that opens this ‘selection’ form. The idea is that the user can double click on the Products they choose from the list box……this is where I’m stuck. VB is my weakness!!! I’m not at all sure on the code for copying from a list box to a table…and this information going to the subform in the right record. I’ve used quite a few different codes for copying fields ..but these are all within the same form..or from text box to text box……

Any help or any ideas will be greatly appreciated…..Thanks a lot in advance to anyone who takes pity!!!!

S
 

Treason

#@$%#!
Local time
Today, 06:32
Joined
Mar 12, 2002
Messages
340
Have u tried to set the Control source of the listbox to the appropiate field in the table?

If you are dealing with Subforms also.. U may need a refresh/requery button. I don't think any VBA will be neccasary.

Cheers
 

Rob.Mills

Registered User.
Local time
Today, 06:32
Joined
Aug 29, 2002
Messages
871
So you've got two tables. One with the list of products from which the listbox pulls the data and then a separate table that contains the records in the order subform. And you want to double-click the listbox and that product will be added to the subform. Am I correct on this?

If so, you probably could use a macro but I would prefer VBA. First make sure the listbox is bound to the id of the product (the field that you want to copy into the subform). Now before I go further... do you want the listbox to remain open after they've clicked it and added the record so that they can click on another selection and have another one added and so forth?
 

JustMaybe

Registered User.
Local time
Today, 11:32
Joined
Oct 18, 2002
Messages
134
Rob.

thank you so much for relpying.....your help is muchos appreciated!!! ..yes i would like the list box to remain open so another selection could be made..

Not sure if this is reelvant ..but the users will still have he option to add products via the oiriginal drop down list on the sub-form...

thanks again..
Sarah
 

Rob.Mills

Registered User.
Local time
Today, 06:32
Joined
Aug 29, 2002
Messages
871
The basic flow for the procedure would be once you've dbl clicked the id of that product (probably a stock no) would be saved as a variable, then that value would be pasted to the correct spot in the subform and then the subform would go to a new record ready to begin the procedure all over. Now I've had challenges before trying to figure out the easiest way to get a subform to move to a different record in code. Maybe somebody else looking at this can shed some light.

I'll give you a sample procedure for copying the info into the subform but it won't move the subform to a new record.

Private Sub ListBoxName_DblClick()

Dim strID as string ' String if it's a stock no with alpha characters

strID=me!ListBoxName

Forms!OrderForm!OrderSubform.Form!TextboxForStockNo=strID

End Sub
 

Users who are viewing this thread

Top Bottom