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

Open Form on Specific Date

Status
Not open for further replies.

BrianBerry

Technical User
Jun 13, 2001
2
US
I am using Access 97 and have a continuous form (named frmOrders) that lists these fields:

Date Customer Address Phone Order etc...

I am trying to make it so when this form opens the records with today's date will be listed at the top of the form (instead of opening on the first record).

I have tried using a couple On Open-Event Procedures for this form (DoCmd.GoToRecord and DoCmd.FindRecord) but can only get GoToRecord to open on a specific record number and can't figure out how to tell FindRecord today's date.

Any help will be appreciated

Thanks!!
 
I assume that this form has no subforms, use a query as frmOrders' Recordsource and set the Date field to a criteria of Date(). That should do what you want. If you then want to scroll through other days just enable a form header and place a field called txtDate on the form in the header. Set the default value property of the field to
Date() and set the criteria of the query to
Forms![frmOrders]![txtDate] and on the fields On Update event place this:

Private sub txtDate_AfterUpdate()
Me.requery
end sub

Try those solutions.

Hope that helps.

Bob
 
Bob,

Thank you VERY MUCH for the help!

Setting the criteria in the query to Date() works great to find all the records with today's date but when I tried the second part to scroll through other days which I need to do doesn't. I created the txtDate field in the form's header and set the criteria in the query to Forms![frmOrders]![txtDate] and when I run the query it still finds all the records with today's date but nothing is displayed in the form. Have any suggestions?
 
Alright, I screwed up (just a little). Set the criteria on for the Date field in the query to Forms![frmOrders]![txtDate]. Then, delete the default value for the txtDate, leave it blank. Now, go to the Form's On Open event and place this code:

Private sub Form_Open(Cancel as integer)
me.txtDate = Date()
me.Requery
end sub

Then you could choose between putting the "Me.Requery" in the txtDate On AfterUpdate event or you could place a button in the header called "Refresh" and after place the Me.Requery in the OnClick event of the button. This way, whenever the user laces a new date in the field, the form will be requeried after they click the button.

Sorry about the mistake in the first thread. Sometimes, you know you've done this thing before, but you get mixed up with the other hundred or so things that you did since then.

Hope that helps!

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top