Solved Copy data from listbox to subform

Noel96334

New member
Local time
Today, 17:27
Joined
Jun 12, 2011
Messages
12
Hi, I'm newbee here and my English is not so good. So I'm going to try to explain my problem.
I have made a order db with main (frmOrderMain) and subform (frmOrderSub1). In the Order main form
I have a listbox with products, populated from the table tblProducts. There is also a combobox to filter the
products in the listbox. So far everything works well.
What I would like to do now, is copy the selected record in the listbox to the subform. I have searched in the
forums and found a solution with a sql-statement. The problem is that I can not modify this for my issue.

Is there anyone who can help me with this please ?

Thanks in advance.
 

Attachments

copy can use either:
sql method:
update t.subtable set [field]= forms!fMasterform!listbox where [id]=forms!fMasterform!txtID

or
just copy value:
me.subform.form.txtBox = forms!fMasterform!listbox
 
Instead of using an unbound listbox in the main form, use a bound combo in the subform. This method requires no coding.
 

Attachments

  • Problem.jpg
    Problem.jpg
    133.7 KB · Views: 123
Note that if you input a large quantity you get the wrong result. Probably because you have the quantity field as byte datatype.
 
It seems I found what's wrong.
This is my mistake - as it turned out, you can not add records to the child table until the record is saved in the main one.
Yes, if you enforce referential integrity.

Usually, I would agree with earlier advice to have instead of unbound listbox and quantity textbox on main form, have bound combobox and textbox on subform; and remove tblProducts from subform RecordSource. Could still have conditional combobox on subform, although that gets a bit tricky with continuous/datasheet form.

Is your issue now solved?
 
Is your issue now solved?
No, unfortunately.
Today I urgently need to fix reporting to the compulsory health insurance fund, not a lot of work, but it needs to be done.
 
Yes, if you enforce referential integrity.

Usually, I would agree with earlier advice to have instead of unbound listbox and quantity textbox on main form, have bound combobox and textbox on subform; and remove tblProducts from subform RecordSource. Could still have conditional combobox on subform, although that gets a bit tricky with continuous/datasheet form.

Is your issue now solved?
YES ! It works well ! Great job ! Thank you so match too all of you !
 
Does the Quantity ever exceed 255? With byte datatype, I think the largest number is 255.
 
Does the Quantity ever exceed 255? With byte datatype, I think the largest number is 255.
Thanks for the reply. Yes I know, the current datatype is "Byte". But we're working with small
volumes, this is sufficient. I appreciate your help ! Thanks so match !
 

Users who are viewing this thread

Back
Top Bottom