Passing textbox data in a query

K

kraasty

Sorry if this post will appear twice, (the first one didn?t make it )


Hello all

When i doubleclick a textbox in a form (in datasheet view) there is macro
that opens a query with the criteria:
Like forms!myform!txtbox1
In this case the query shows only specific record i clicked on

But when I put this form as a subform to another form & doubleclick on the
textbox
the query shows nothing
Can anyone suggest something? thanks
 
K

Ken Snell [MVP]

When you use a form as a subform in another form, that 'now' subform no
longer is "open" on its own, and references such as the one you're using
won't work as written. Instead, the 'now' subform is a child of the form in
which it's being used as a subform. The correct reference to it now is

Forms!MainForm!SubformName!ControlOnSubform

Note that "SubformName" is the name of the subform control (the control that
holds the subform, which may or may not have the same name as the form that
is serving as the Source Object of that control).
 
V

Van T. Dinh

The reference to the TextBox (in the Query) needs to be changed to:

Forms!MainForm!SubformCONTROL.Form!TextBox1

You need to check the name of the SubformCONTROL in the design view of the
MainForm. It may or may not be "MyForm" as per your reference.
 
K

kraasty

Thank you very much Ken and Van for your help.
I corrected the reference to the control and now it works fine!
 
K

kraasty

Thank you very much Ken and Van for your help.
I corrected the reference to the control and now it works fine!
 
Top