View Single Post
  #7  
Old April 21st, 2010, 08:11 PM posted to microsoft.public.access.forms
Mommybear
external usenet poster
 
Posts: 37
Default Populate a form based on a query using parameters

My form is populated when I open it, which I really don't want it to do. I'm
just working on one problem at a time. I want it to open to a blank screen,
the user will enter the code they want to see, hit the search button, then
have the query run and the data populate. My data could be anywhere from 1+
lines so I have a header that is set up to list the info that is the same on
each record such as the code that is being searched, the item description and
category. The remaining data will display in the detail section as it defers
for each record such as location.

"Daryl S" wrote:

Mommybear -

My understanding is your form is populated when you open it. Then you enter
something into a text box and click the Search button and expect the form to
now contain records based on the search criteria. If this is the case, then
in your Search button, instead of RunQuery (which will open a query in
datasheet mode in a new window), you want to re-query what is displayed in
the form based on the record source for the form. In that case, add this
code in your click event of the search button:
Me.Requery
That will cause the records on the form to be refreshed from the database
based on the current record source.

If your form is not populating at all, then make sure the controls (text
boxes, etc.) are bound to fields in the record source (the Control Source
property for each control has a field name from the query).

If you are using a main form with a subform, then let us know, as that would
mean a different answer. If this posting doesn't help, please be more
specific about what you are changing (what does the Search button do), and
what is not working...

--
Daryl S


"Mommybear" wrote:

It is my recordsource. I just don't know how to get the data to appear on
the form. What is a Me.Requery and where do I add this. I'm sorry, I'm
really not that familiar with Access.

"Daryl S" wrote:

Mommybear -

RunQuery will open a query, which is not what you want. What you want is
for this query to be the recordsource for the form. Then if you change this,
you just need to do a Me.Requery.

--
Daryl S


"Mommybear" wrote:

I have created a form that is populated from a query. I have a text box set
up as an input box and click a button (Search) to execute the search. This
appears to be working fine as the query opens and runs. However, it displays
in the query in data format instead of in the Form I created. How do I get
this information to populate the form, not the actual query. The Search
button is set to RunQuery.