Solved

Access 2000 query to out put data between a date range

Posted on 2004-04-12
4
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

726 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