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

Default date Parameter Prompt 2

Status
Not open for further replies.

JOEYB99

Technical User
Joined
Jul 9, 2008
Messages
121
Location
CA

I am using Access 2003 and developing a simple query with a parameter prompt of a date field.

The majority of the time this date will be the day prior to today, i.e. yesterday. So when the parameter prompt comes up I want the user to see yesterday's date filled in, the user has the option to over-ride it.

How do I achieve this effect?
 
How are ya JOEYB99 . . .

Well ... with following the previous date is not filled in, but it is a part of the prompt. I use a function here to make things easy, so copy/paste the following to a module in the modules window:
Code:
[blue]Public Function ParaDate() As Date
   Dim inDate As String
   inDate = InputBox("Input a date! (yesterday was " & Date - 1 & ")", "Date Entry Required! ...")
   
   If IsDate(inDate) Then
      ParaDate = CDate(inDate)
   Else
      ParaDate = CDate(0)
   End If
   
End Function[/blue]
Then in the criteria line of the Date in your query, enter [blue]ParaDate()[/blue], and perform your testing!

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thank you Aceman for the prompt reply.

However, I'm not a VB man. Would you know how to do this within the standard Query design screen?
 
It can not be done directly in a query, but AceMan gave you a turnkey solution.
1)Select "New","Module" and the vba developer window should open.
2)Copy and past the code into the module.
3)Then use the function in a query as suggested
Then in the criteria line of the Date in your query, enter ParaDate()
, and perform your testing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top