Full Version: How can i get this form to pass the data to the query?
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
benracer
Hello,

I have a table that contains various coumns, this is named Members.

I also have a query that that works when run using the standard parameter 'pop up', this is named mainquery.

I have created a form with a text box names qid1, i would like to pass the data entered here into the query (mainquery).

I have tried to use the folloing code allthough nothing happerns when the field loses focus....

Private Sub qid1_LostFocus()
DoCmd.OpenQuery "mainquery", acViewNormal, acEdit
End Sub

Many Thanks,
Ben
DougY
Welcome to Utter Access Forums!

What you are looking for is called Query by Form (QBF).

Check out this Microsoft KB article on the subject.
theDBguy
Welcome to Utter Access!

If I understand your question correctly, change the popup parameter in your query from something like:

[Enter ID]

to

Forms!NameOfYourForm.qid1

Hope that helps...
benracer
Thanks for your replies - and the warm welcome!

I have read through the the kb page and i have found the difference in my script.

They use the macro method of opening the query from the form, is there a way to do this in VB?

I have found this informaton...
http://msdn.microsoft.com/en-us/library/bb238028.aspx

However nothing happerns when the button is clicked.

Regards,
Ben

Edited by: benracer on Thu Nov 27 17:22:54 EST 2008.
theDBguy
You might want to post a small copy of your db with test data (and also an Acc2003 version), if you can, to help us understand what you're going through.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.