Solved

Access 2000 query to out put data between a date range

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

749 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