Solved

Access 2000 query to out put data between a date range

Posted on 2004-04-12
4
192 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

813 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

11 Experts available now in Live!

Get 1:1 Help Now