Creating form to select records between two dates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • as323
    New Member
    • Mar 2009
    • 1

    Creating form to select records between two dates

    Hi There,

    I am quite new to Access 2003 and am looking for someone to help me with a project im starting on.

    I currently have a query that is run which will pull up records on selected data and in the design view I put dates between two dates in the criteria.

    I want to create a form that will be the front end where a week beginning date and week ending date can be entered - and this will then be able to run the query with these dates in the front end form as the criteria for the records to pull up.

    Does this involve me having to write som VB with the the existing standard code for the run query button:
    Code:
    Private Sub RunRTTCof_Click()
    On Error GoTo Err_RunRTTCof_Click
    
        Dim stDocName As String
    
        stDocName = "All_Outpat_Week"
        DoCmd.OpenQuery stDocName, acNormal, acEdit
    
    Exit_RunRTTCof_Click:
        Exit Sub
    
    Err_RunRTTCof_Click:
        MsgBox Err.Description
        Resume Exit_RunRTTCof_Click
        
    End Sub
    thnaks
    Last edited by NeoPa; Apr 4 '09, 03:12 PM. Reason: Please use the [CODE] tags provided
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32653

    #2
    No. Just refer to the controls on the form within the query.
    Code:
    ...
    WHERE DateField Between [Forms]![YourFormName].[FromDate] And [Forms]![YourFormName].[ToDate]

    Comment

    Working...