User Input

A

Ang

Hi,

Could someone please tell me how I would make an append query based on user
entry into a subform. I can create an append query from the combo boxes on
the main form but having trouble with the subform which is text (not combo
boxes). It keeps asking for the parameter value even though it is entered in
to subform. Any advice would be appreciated.

Ang
 
J

John Spencer

If you are trying to refer to a control in a subform in a query, I
believe you are out of luck. As far as I recall, you cannot refer to a
subform control in a query.

You could build the query on the fly or you could have a control on the
MAIN form that gets assigned a value based on the whatever is selected
in the control in the subform. Then you could refer to the control on
the main form. The Control on the main form could simply be an unbound
invisible textbox.

In the sub-form you would need something like this bit of code in the
appropriate events.

Me.Parent.NameOfControl = Me.txtbox

Probably would want that code in the after update event of the txtbox
and possibly in the on current event of the subform.

Another option would be to use a custom vba function to get the value.
And call that in the query instead of using the reference directly.

Public Function fGetValue()
fGetValue = _
Forms!MainForm!NameOfSubFormControl.Form.NameOfControlOnSubForm
End Function

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top