TextBox Query

liam_conor

Board Regular
Joined
Oct 9, 2002
Messages
180
I can't figure this one out...

He is my situation. I have two forms that a user enters data into. One is the MainForm and the other is a SubForm. First the user enters his/her information in the MainForm and the clicks a command button that opens a SubForm. During the action a value is passed from the MainForm to the SubForm. (Statement Below)

Forms![frm_subvalue_waste_entry]![area_id] = Forms![frm_production_entry]![area_id]

This value is stored in the SubForm's area_id textbox. What I would like to do is use the value stored in area_id for a query. That query will return a value to another textbox productiontype_id. I cannot achieve this... Here is my query below:

SELECT
tbl_productiontype.productiontype_id
FROM
tbl_productiontype
WHERE
((tbl_productiontype.area_id)=Forms!frm_subvalue_waste_entry!area_id);

Can anyone help me??? Or does this not make any sense?
 

Some videos you may like

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

VicRauch

Well-known Member
Joined
Mar 23, 2006
Messages
2,032
the syntax to get at a sub form is:
Forms!frmMainForm!subformName!fieldName
So, as I read your form names, it would be:
Forms!frm_production_entry!SubFormControlName.Form!area_id
Generally speaking, the SubFormControlName is the same name as the form that is being used as the subform. In your case that would be "frm_subvalue_waste_entry"
HTH
BTW, I would think you would be using area_id as the Child and Master linking fields for the subform.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,060
Messages
5,545,761
Members
410,704
Latest member
Cobber2008
Top