Hi guys, Please could somebody show me how to use the data entered in a form, to be the criteria in a query?
Regards Zac
Hi guys, Please could somebody show me how to use the data entered in a form, to be the criteria in a query?
Regards Zac
Let's say that you enter a value in a textbox on your form (fmYourFormName), and that the name of this textbox is 'txtYourTextBox'.
Then, you would put the following in the criteria row of the relevant query field:
Now, that works if your text box is on a regular form, but it will not work if the textbox is on a subform. For that, you need to tell Access both the form name, AND tell it to reference the subform.Code:[Forms]![fmYourFormName]![txtYourTextBox]
But to properly understand this, you need to understand a little more about subforms.
When you place a subform on a form you are actually placing a subform control onto the form: not the form that you see within that subform control. In a sense, this subform control is just a container.
Within this container, there is a source object property which refers to the actual form which becomes the subform.
So, how does this relate to a parameter query?
When you use a subform control as a parameter for your query you will need to specify the container name, and then specify the name of the control on the form object within the container.
eg
Hope that helps.Code:[Forms]![fmYourFormName]![SubformContainerNameHere].Form![txtYourTextBox]
I have a similar issue. I can get a query to work properly when launching from the main db window (with the form open in another window) with theLet's say that you enter a value in a textbox on your form (fmYourFormName), and that the name of this textbox is 'txtYourTextBox'.
Then, you would put the following in the criteria row of the relevant query field:
Now, that works if your text box is on a regular form, but it will not work if the textbox is on a subform. For that, you need to tell Access both the form name, AND tell it to reference the subform.Code:[Forms]![fmYourFormName]![txtYourTextBox]
But to properly understand this, you need to understand a little more about subforms.
When you place a subform on a form you are actually placing a subform control onto the form: not the form that you see within that subform control. In a sense, this subform control is just a container.
Within this container, there is a source object property which refers to the actual form which becomes the subform.
So, how does this relate to a parameter query?
When you use a subform control as a parameter for your query you will need to specify the container name, and then specify the name of the control on the form object within the container.
eg
Hope that helps.Code:[Forms]![fmYourFormName]![SubformContainerNameHere].Form![txtYourTextBox]as criteria for a field. However, if I add a button in the form containing the dropdown to launch the form, it doesn't work. I tried 'printing' the value to the query to see what WAS being passed, and it seems nothing at all is. Anyone know why this might be?Code:[Forms]![fmYourFormName]![dropdown].[text]
Thanks in advance