Solved

Access 2000 query to out put data between a date range

Posted on 2004-04-12
4
186 Views
Last Modified: 2008-03-10
I need to either a query or a macro that will seach tables for data that when run will prompt the user to enter a start date and an end date or search for one date in particular then output the data to the printer. Sorry if that doesn't make any since. let me know if it doesn't and I'll try to explain further.

thanks

PC Cowboy
0
Comment
Question by:PC-Cowboy
4 Comments
 
LVL 32

Accepted Solution

by:
jadedata earned 50 total points
ID: 10806343
Greetings PC-Cowboy!

 SQL for a query

  SELECT * FROM TableName WHERE ([DateFieldInTable] between # & [Starting Date] & # and # & [Ending Date] & #);

  YOU have to make sure the dates will not cause errors in this context.

regards
jack
0
 
LVL 39

Expert Comment

by:stevbe
ID: 10807823
I usually use a form to verify user's input before executing anything :-)

Private mblnValid As Boolean

Private Sub txtStartDate_AfterUpdate()
    If IsDate(Me.txtStartDate.Value) = False Then
        MsgBox "Please enter a Starting Date in 'mm/dd/yyyy' format"
        Me.txtStartDate.SetFocus
        mblnValid = mblnValid AND True
    End If
End Sub
Private Sub txtEndDate_AfterUpdate()
    If IsDate(Me.txtEndDate.Value) = False Then
        MsgBox "Please enter an Ending Date in 'mm/dd/yyyy' format"
        Me.txtEndDate.SetFocus
        mblnValid = mblnValid AND True
    End If
End Sub
Private Sub cmdExecute()
    Call txtStartDate_AfterUpdate
    Call txtEndDate_AfterUpdate

    If mblnValid = True Then
        'all is good, do whatever ...
    End If
End Sub

of course you could use calendar control or build a form that looks and acts like a calendar control (no activeX registration required) and then they cannot enter a bad date if you call a public function directly within the query and that function returns a date from your calendar form ...

Steve
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now