Connecting Tech Pros Worldwide Forums | Help | Site Map

getting criteria match from other form's textbox

Newbie
 
Join Date: Jan 2008
Posts: 7
#1: Jan 7 '08
hi, just wondering how can i get a value from a text box on a different form to apply in a query, can i do this in query criteria? or i have to make a vb code in command click?

i have a form with a textbox, and a command click, what i want, once click it will open a query form base on the value of the textbox, it would be easy if i could use the query criteria part but seems like i cant do that, so i might need a vb code advise if ever i wont be able to do this, thanks

Megalog's Avatar
Expert
 
Join Date: Sep 2007
Posts: 273
#2: Jan 7 '08

re: getting criteria match from other form's textbox


I do this all the time... In your query, in the Criteria box, put:
[Forms]![FormName]![ControlName]

For example, say the Query is looking up Employee information, and you want it to filter out only the relevant information for the employee you have selected in a combo box.

Form: frmEmployeeDetails
Control: cboEmployeeFilter

you'd use this as your criteria:
[Forms]![frmEmployeeDetails]![cboEmployeeFilter]

Now, this only works if that referenced form is open obviously, so use this criteria only in cases where something is being called from an open form.
Reply


Similar Microsoft Access / VBA bytes