Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying from a List Box to a SubForm

Status
Not open for further replies.

JustMaybe

Technical User
Oct 18, 2002
5
0
0
GB
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…on 'double click' and this information going to the subform in the right record.as there is no common ID. 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

 
If I understand your problem I think the easiest way to accomplish this might be to use a list box of your products populated by a query. Followed by an ActiveX listbox for the products the user has chosen. The user selects an item in the listbox and clicks an add to order button which writes to the corresponding table and adds an item to the order listbox. With an activeX control its easy to add to the list at runtime using the .AddItem method. The code should look something like:
Code:
dim strSelected as string
dim strsql as string

strSelected=[Forms]![MainFormName]![SubFormName].[Form]![lstbox]
xListBox.Object.AddItem strSelected
strsql= "INSERT INTO TableName(OrderedItem) VALUES('"& strSelected &"')"
docmd.runsql strsql
I hope this should at least give you an idea. Let me know if need any more code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top