Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access 2000 query to out put data between a date range

Posted on 2004-04-12
4
Medium Priority
?
202 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 200 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

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…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

610 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