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

Form Loading with Specific Records

Status
Not open for further replies.

tnago

Technical User
May 21, 2003
23
CA
Hi

I am trying to get my form to load records from a specific time frame (e.g only year 2003 records or from a specific record id)and with most recent record as the record being displayed in the form. Also can we show all the records in the form if user so desire. Any suggestion?
 
Below is the easiest way I know how.

1. Create 2 queries, 1 that pulls records for 2003 and another query that pulls all records.

Example of 1st query:
SELECT Table1.field1, Table1.Year
FROM Table1
WHERE (((Table1.Year)="2003"))
ORDER BY Table1.ID DESC;

Example of 2nd query:
SELECT Table1.*
FROM Table1
ORDER BY Table1.ID DESC;;

2. Set your forms Data property to query1
3. Add a button to your form that says "Show All" and add the following code to the OnClick event property:
Me.RecordSource = "Query2"
Me.Requery

hope this helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top