Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running queries through forms from FAQ's.

Status
Not open for further replies.

banco

Technical User
Jul 9, 2002
11
0
0
US
I've been trying to contact the person that wrote "How to run queries through forms?" in FAQ's and I had no luck. Therefore I'm asking for help. I've tried doing his ex. but it does not work, When I run the query I get a blank datasheet with the Name, Position and Shift fields but no data on it.
Also in line 5 he mentions "with the control source of that form being "Employee_Query".
Where do you get the opion to see "control source" for the form (Employee_Form).
As I set it up I only get the reference ID# (auto#) in the Employees table in the name field. (weird?)
Let me show you the actual post:

How to run queries through forms?
faq702-1251

What you want to do is to create a form that list all of the positions in a combobox and run a query from the selection of that combobox.

1) Create a table called “Position” with “Position” as a field name
The data in your table such look like this:

“Position”
Manager
Supervisor
Associate

2) Create a table called “Employees” with “Name”, “Position”, and “Shift” as field names. The data in your table such look like this:

Name Position Shift
Kim Supervisor 3rd
Mike Manager 2nd
Chris Associate 2nd

3) Save the table and create a query called “Employee_Query” with the following fields:

Name Position Shift

4) Place the following criteria under the “Position” field:
=[Forms]![Employee_Form]![Position_combobox]

5) Save the query and create a form called “Employee_Form” with the control source of that form being “Employee_Query”.

6) Create a combobox using the wizard that will lookup the values in the “Position” table.

7) Name this combobox “Position_combobox”.

8) Create a button using the wizard that will run the “Employee_Query”

9) Save the Form

10) Go to design view, choose a position, and press the button.

If someone can see what's wrong please let me know.

Thanks...
 
Do not understand step 4. Why do you not use the wizard on your positions table and a combobox loaded with 'position' telling it to load the output in a field in the form?

Rollie E
 
A form does not have a control source. A form has a record source. If you were building a form based on a table or a query, this is were you place the name of the table or query the form is based on. That's not the purpose of the form in his example. He's created a 'blank' form (one with no record source) on which he's placed an unbound combobox and a button to run the query. So..

Revised step 5:
Create a blank form and save it as Employee_Form (because your query is going to look in that form to find the value in Position_combobox)

Using the wizard, create a combobox. When it asks for which query or table should provide the values for the combobox choose the position table. When the wizard finishes, you should see an unbound combobox on the form. right-click on it and look at the properties. The name property will be something like Combo2. That's the name the wizard gave it. You need to change it to Position_combobox because that's what your query is looking for.

Add the button to run the query, save the form.

Is that better?
 
Thank you Rollie but I did not design the form, read the entire thread...

sko,

I understand what you explained and I did it but it still doesn't come out. Let me explain:

When I select a position in the Position_combobox and run the query it still gives me a blank datasheet. I did change the name property on the Position_combobox and it didn't make a difference.

Let's say I select "Supervisior" isn't the output suppose to be Kim Supervisor 3rd ?
Since the combobox will look up the values in the positions table how can it output Name, Position and Shift data? I understand that the query that we did should take care of this but the output is blank. Does it have to do with the combobox looking up values in the "Postions" table which only has the "postions field" and not gettingit from the Employee's table which has all of them?

Hope you can answer me...
Thank you
 
Ok, let's start over (almost).
Open Employee_Query in design view and remove the criteria. Run the query. Does it return all the records from the Employee table?

Have you ever created a parameter query?
 
Ok, let's start over (almost).
Open Employee_Query in design view and remove the criteria. Run the query. Does it return all the records from the Employee table?

Have you ever created a parameter query?
 
Sorry for the double-post. Maybe it's a spelling error since the sample data was entered directly in the tables without referential integrity set. Check "Supervisor" in both tables.

 
sko,

I was out of town and I did not have access to a computer, sorry for the delay. But let me tell you that I did it from scratch today and it worked!

Thank you for taking the time to answer me and for all the help...

banco
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top