When passing a value from a form field to a query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can the value come from a combo box or list box? I'm using Forms![your form
name]![select control] in the query criteria to get the value from the form.
 
Yes to combo box, maybe to list box. What you've got will only work for list
boxes that don't allow multiselect. If you want to use multiselect, you'll
need to use a different approach: one that rewrites the SQL of your query
based on what's selected, for example.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


DV said:
Can the value come from a combo box or list box? I'm using Forms![your form
name]![select control] in the query criteria to get the value from the
form.
 
I am having similiar problem - except I'm trying to refderence subform. I
think I have a sytactical error - but can't get it. I'm using -
[forms].[formname].[form].[subformname].[fieldname]



Douglas J Steele said:
Yes to combo box, maybe to list box. What you've got will only work for list
boxes that don't allow multiselect. If you want to use multiselect, you'll
need to use a different approach: one that rewrites the SQL of your query
based on what's selected, for example.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


DV said:
Can the value come from a combo box or list box? I'm using Forms![your form
name]![select control] in the query criteria to get the value from the
form.
 
You need to use

[forms].[formname].[nameofsubformcontainer].[form].[fieldname]

nameofsubformcontainer is not necessarily the name of the form that's being
used as the subform. If you created the subform by dragging a form onto the
parent form, they're probably the same. However, if you selected the Subform
control from the tool box, added it to the parent form and let the wizard
help you add the subform, the container's probably named something like
Child1.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


David said:
I am having similiar problem - except I'm trying to refderence subform. I
think I have a sytactical error - but can't get it. I'm using -
[forms].[formname].[form].[subformname].[fieldname]



Douglas J Steele said:
Yes to combo box, maybe to list box. What you've got will only work for
list
boxes that don't allow multiselect. If you want to use multiselect,
you'll
need to use a different approach: one that rewrites the SQL of your query
based on what's selected, for example.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


DV said:
Can the value come from a combo box or list box? I'm using Forms![your form
name]![select control] in the query criteria to get the value from the
form.
 

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

Back
Top