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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying results of a query 2

Status
Not open for further replies.

alt131

Technical User
Dec 31, 2000
17
NZ
Dear all,
Am new to databasing, new to Access and finding the Help less intuitive than other windows app I have tried to learn. Please excuse me if this is a dumb question and the languae I have used is all wrong. Please don't swear at me for being 'ignorant' as someone else did in another forum - - just refer me to the help section or a tutorial.

My scenario is this: I want to query a data base and have the results of that query display. For example all people with the name 'Bloggs' born in year 1972 or all Bloggs born in the year 1984

Problem is this: I to have to put in text boxes for the results to display. I will not always know how many boxes I need becasue I won't always know how many are necessary. Plus, in trying, even if I put in many boxes, they all only show the same record.

Question is this: Is there a way to build my query or form so that if there were 10 Bloggs born in 1972, 10 Bloggs will be listed and if there are only 1 born in 1984, only only 1 is shown (and account for the fact hthat in other years a different number of records will be returned?

I hope my lack of understadning didn't make this impossible to figure out. Any help is appreciated.
alt
 
Hi,

There are a few ways to display a query result. You can simply run the select query and the results will be displayed the way you want in rows and columns. This is known as datasheet view. You can also make your form display the results in a datasheet view. If you want to display the result in a form then simply assign the name of your query to the recordsource property of the form. Once you do that you can then click on the fields list while you are in design view of your form, drag and drop the fields onto your form. Normally, they will become bound textboxes. Each textbox will represent a field in one record. It won't matter how many records are returned by your query since in this view (form view) you only see one record at a time. Another view is known as continuous view which shows more than record on the screen but each record is divided by a line.

Have a good one!
BK
 
Hi,

To add a little to what BK has said, you can solve your problem a host of (easy) ways, depending upon how you want your info returned.

I'm not sure how much you understand the relationship between form and query, so:

First the query:
Create a new query for your existing table (click query tab, click new, select design view);
Select then add the table you are working from, then close the Show Table Dialogue;
In the Table dialogue(?), doubleclick the name field and the year field, which will add these (and any other fields) to the qbe grid;
In the first row of the criterea, and under the fields you want to filter by, include a question inside sq brackets, eg [What name?], and [What year?] (if you want this as OR, place in seperate rows;
Run the query.

Now when the query is run, the user will be prompted to enter a name and a year before returning the required data. You can then base a form on this query to display as a single record, continuous forms, or as a dataset etc as BK suggested.
Note that the year will be a whole number, and that if you have a date in you year field (eg 1/1/2001), then entering "2001" at the prompt will not return the expected info. This can be dealt with, but for now...

Create the form:
Close & save the query (eg qryNameAndYear);
On the menubar, select Insert >> Form;
On the New Form dialogue, select Form Wizard and make sure your new query is the objects (forms) source data;
Follow the prompts, and Access should create the form you are happy with;
Go into the form design and have a play;

When you open the form, as it is based on the query, it will prompt you for the name and year whenever you first open it. Forms simply display a record at a time, and the records are each line in a dataset returned from a query or from a table.

Cheers
 
Wow!! I understood all that .. and best yet it works, and better yet I then figured out how to make a continuous form that displayed what I wanted.

Now I have even more questions ... but Thank You both so very much for explaining this in a way that I could understand.

alt131
 
I will list 4 very important things I have learned about access and Tek-Tips
1. There are no stupid questions.
2. There are no stupid questions.
3. I ask a lot of stupid questions.
4. The people in this forum have helped me tremendously, even though I am far below most of their abilities, often times giving me 3 or 4 different ways to do things when the first suggestions are to complicated for me.
-Smack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top