how to show just one row

  • Thread starter Thread starter tim
  • Start date Start date
T

tim

Hi there!

I am working on a smal search program in MS Access 97. I
have a list with some info from a tabel. whan a user
clicks on a field, the program has to show the information
that belongs to the row this field is out of, in a
rapport. When I try to make this, I get a rapport with all
the information out of al the rows, insted of only the ony
I chose. how can I solve this? I probably need to use a
qurry in between of mij form and mij rapport. what should
I put in it?

thanks already,

Tim
 
tim said:
Hi there!

I am working on a smal search program in MS Access 97. I
have a list with some info from a tabel. whan a user
clicks on a field, the program has to show the information
that belongs to the row this field is out of, in a
rapport. When I try to make this, I get a rapport with all
the information out of al the rows, insted of only the ony
I chose. how can I solve this? I probably need to use a
qurry in between of mij form and mij rapport. what should
I put in it?

What statement are you currently using? You need to use the WHERE argument of the
DoCmd.OpenReport command. That will open the report with a filter applied. The
query the report is using could also refer to the listbox for its criteria, but that
is a bit less flexible than using the WHERE clause.
 
Hello Tim,

It sounds like you are driving your report with data
directly from a table. This is not the best way to do
things because it doesn't allow you to "SELECT' the
records you want and instead it forces you to use all of
the records in the data table.

Also, this prevents you from using one of the most
important functions of a 'Relational Database' which is
the selection of the data you desire (from one or more
tables) by the use of selection criteria in a query!

All Forms and Reports should be populated with data from a
Query!!!!!

In your case, in order for you to select the row of data
that you want, do the following:
1) create a query using the data table containing the data
you need. This means that, from the 'Database window',
select 'Queries' and then click on 'NEW'
2) When the small 'New Query' window is displayed, choose
the 'Design View' option.
3) The next window will be the query design window. This
is an area that you will see quite often as you build your
application. In this window you will see the 'Show Table'
window. Highlight the data table that you want to work
with and then click the 'ADD' button.
4) When the table is displayed above the divider bar, you
can click the 'Close' button. (when you get into building
multi-table queries, this is where you would select all of
the needed tables to be added to the query).
5) Now highlight all of the fields that you need to use in
the selected data table box and drag then down to the grid
below the divider bar.
6) Once you have all of the desired fields in the design
grid, click on 'Query' in the menu bar at the top of the
window and select run. What you will see displayed is data
that looks just like the data table; but it is not the
data table, it is a temporary dataset (also known as a
dynaset) that was selected by the query and is kept in
memory until you are finished with it.
7) Now you have a query with the data but it still doesn't
select just the records you wanted in the first place. The
next step is to turn this simple query into a 'Parameter
Query'. Parameters are used to tell the query which
records are wanted.
8) Go back to 'Design mode'. Now look at the design grid.
you will see labels for each of the rows in the design
grid. The parameters will be added to the 'Criteria' cells
below the fields in the following way : Type in
the '[selection text]' without the quotes. In other
words, if this was a last name field (column) in the data
table, I would type the following into the criteria cell
of the column '[Enter the desired Last Name]' without the
quotes. When you run the query, it will then display a
small window that asks says 'Enter the desired Last Name'.
After you enter the desired Last Name, only records
containing your entry will be displayed! Also, if there
are no records with the entered last name, no records will
be displayed.

I hope this helps, and remember that this is just the
beginning. Also, please read up on the criteria options
such as 'AND', 'OR', 'Like', 'Is Null', etc....

Pete Sheridan
 
Back
Top