Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2005
    Location
    Somewhere on the 3rd Rock
    Posts
    93

    Unanswered: Missing something

    I have this form and I need it to show a report named Rpt_Patrols

    The fields are called the following

    txtPatrolSector
    txtStartDate
    txtEndDate
    txtStartTime
    txtEndTime

    Here is the code I have gotten to work so far.

    Code:
    Option Compare Database
    
    Private Sub PreviewPatrolReport_Click()
    On Error GoTo Err_PreviewPatrolReport_Click
    
        Dim stDocName As String
    
        stDocName = "Rpt_Patrols"
        DoCmd.OpenReport stDocName, acPreview, , "[PatrolDate] Between #" & Me.txtStartDate & "# And #" & Me.TxtEndDate & "#"
    
    Exit_PreviewPatrolReport_Click:
        Exit Sub
    
    Err_PreviewPatrolReport_Click:
        MsgBox Err.Description
        Resume Exit_PreviewPatrolReport_Click
        
    End Sub
    I got this code to work but it sorts returns the wrong data. I need data between the start time and the end time. If I put in 22:00 to 06:00 I only get data prior to 22:00, and after 06:00.

    Code:
    Option Compare Database
    
    Private Sub PreviewPatrolReport_Click()
    On Error GoTo Err_PreviewPatrolReport_Click
    
        Dim stDocName As String
    
        stDocName = "Rpt_Patrols"
        DoCmd.OpenReport stDocName, acPreview, , "[PatrolTime] Between #" & Me.txtStartTime & "# And #" & Me.TxtEndTime & "#"
    
    Exit_PreviewPatrolReport_Click:
        Exit Sub
    
    Err_PreviewPatrolReport_Click:
        MsgBox Err.Description
        Resume Exit_PreviewPatrolReport_Click
        
    End Sub
    I am not sure how to code for the Drop down menu, or how to combine all three of these to work together.
    Will Dove
    working hard is better then hardly working ...

  2. #2
    Join Date
    Dec 2005
    Location
    Somewhere on the 3rd Rock
    Posts
    93

    a Little Closer but still not there

    I had a little help from CyberLnyx, but it still did not get me where I need to be. I still need to figure out how to make the dropdown work with this and how to get the time to sort correctly.

    here is the code.

    Code:
    Option Compare Database
    
    Private Sub PreviewPatrolReport_Click()
    On Error GoTo Err_PreviewPatrolReport_Click
    
        Dim stDocName As String
    
        stDocName = "Rpt_Patrols"
        DoCmd.OpenReport stDocName, acPreview, , "[PatrolDate] Between #" & Me.txtStartDate & "# And #" & Me.TxtEndDate & "# AND [PatrolTime] Between " & Format(Me.txtStartTime, "hh.mm") & " And " & Format(Me.TxtEndTime, "hh.mm")
    
    Exit_PreviewPatrolReport_Click:
        Exit Sub
    
    Err_PreviewPatrolReport_Click:
        MsgBox Err.Description
        Resume Exit_PreviewPatrolReport_Click
        
    End Sub
    Will Dove
    working hard is better then hardly working ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •