condition

W

Wendy

Hi, I'm new to databases and I have a question about a report I created using
the wizard. I want have a list of employees, salaries and type of salaries.

I have grouped it by Type of salary, but I only want to display if teh type
of salary matches values: "A1" or A2 and do not display anything else. Can
anybody tell me how to accomplish this?
 
A

Al Camp

Wendy,
In the query behind your report, you should be able to filter out all
those records with a Type that's not A1 or A2. Using the query design
grid...
="A1" goes on the Criteria line and
="A2" goes on the next line down (OR)
Only A1 and A2 records will be returned.
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
 
W

Wendy

Never mind, I entered the criteria under total salary instead of type of
salary, this was really helpful, thanks much!
 
S

Sprinks

Hi, Wendy.

This message means one of the report controls has a Control Source set to
"Total Salary", but this field is not in the query. Since all the fields
from the original table *are* selected, I would guess that the report's
original RecordSource was a query in which the Total Salary was a calculated
field. If this is the case, simply go to the original query and add the two
criteria rows to the Salary Type field, and reset the report's RecordSource.

Sprinks
 
S

Sprinks

Hi, Wendy.

You limit the records selected either by a report filter or through a query
that selects the records you want. I suggest the latter as it is more
straightforward and visual.

Start a new query, and select the table on which you wish to base the
report. Close the table selection window, and double click the asterisk at
the top of the table's field list to select all the fields in the table, then
click the SalaryType field, and deselect it by unchecking its box in the
Show: row. In the first criteria row, type A1, and type A2 in the next row.

Criteria entered in subsequent rows of the same field creates a logical OR
statement, while multiple criteria in the same row of multiple columns
creates a logical AND. Choose View, SQL to see the SQL for this query. The
WHERE clause selects the records you want.

Save the query, and reopen your form. Show the form's properties with View,
Properties, and change the RecordSource property to the name of your query.

This example is "hard-wired" in that your selection cannot be modified by
the user at runtime. After you get this working, you can try a parameter
query, or a form-based selection method, whereby the user enters one or more
criteria, and you use code to build the SQL selection string.

Hope that helps.
Sprinks
 
W

Wendy

Thank you, I did the query, however I was working on a report, not a form. I
reopened the report and changed the Record source to point to the query, but
I when I run the report I get a box asking me to enter a Parameter Value fopr
Total Salary. Any suggestions?
 
Top