Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    Susy is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    134
    Hi there,



    after the issue with the date format was solved, I thought about creating a date range... but it is not working... below some snapshots of the code and error message...

    my variable declaration for this case looks like this...

    From Date: Dim strActfDate As String,
    To Date: Dim strActtDate As String,
    From and to: Dim strActftDate As String


    Click image for larger version. 

Name:	formBetweendates.JPG 
Views:	12 
Size:	10.9 KB 
ID:	28268


    Code:
    If IsNull(Me.cboActionfDate) and isNull(Me.cboActiontDate) Then
                     strActfDate = "[ActionDate] like '*'"
                     strActtDate = "[ActionDate] like '*'"
             Else
                    strActftDate = "[ActionDate] = BETWEEN #" & Format(Me.cboActionfDate, "mm\/dd\/yyyy") & "# AND #" & Format(Me.cboActiontDate, "mm\/dd\/yyyy") & "#"
        End If

    Click image for larger version. 

Name:	Betweendates.JPG 
Views:	12 
Size:	22.8 KB 
ID:	28267


    Can someone see the error?

    Regards and happy eastern!

  2. #17
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    VBA Date will not be read. Date parameter as Date defined, still no progress!

    No equals if I remember

    Could be is between


    Sent from my iPhone using Tapatalk

  3. #18
    Susy is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    134
    Yes...

    thanks

  4. #19
    Susy is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    134
    Hi again,

    after andy49 helped me with the date format and sql issue, now I have been fighting with another problem....

    when I set one filter from the combo boxes (see image), I am not able to requery the other filters so they show in their lists the only options available.
    Click image for larger version. 

Name:	filters.JPG 
Views:	37 
Size:	71.4 KB 
ID:	28287


    For example, if I were to select the Status "confirmed", then only name available under the filter "Sales Organizer" should be Mtendere Chakuamba. Right now I get all 9 different names saved in that field.
    Click image for larger version. 

Name:	filter_sales organizer.jpg 
Views:	37 
Size:	19.5 KB 
ID:	28289
    Click image for larger version. 

Name:	filter_planned.JPG 
Views:	36 
Size:	28.2 KB 
ID:	28288


    This is what my form, subform (from the table report) looks like...
    Click image for larger version. 

Name:	filter_table_subform.JPG 
Views:	36 
Size:	86.9 KB 
ID:	28290

    and the code...
    Code:
    Private Sub cboStatus_AfterUpdate()
    
    
        Call SearchCriteria("[ReportID]")
    
    
    End Sub
    
    
    Private Sub cboType_AfterUpdate()
        
        Call SearchCriteria("[ReportID]")
    
    
    End Sub
    
    
    
    
    
    
    Function SearchCriteria(myString As String)
    
    
    Dim strSOReportNo As String, strStaName As String, strTypeID As String, strSalesOrg As String
    
    
    Dim strActDate As String, strActfDate As String, strActtDate As String, strActftDate As String
    
    
    
    
    
    
    Dim task As String, strCriteria As String
    
    
        If IsNull(Me.cboSOReportNo) Then
            strSOReportNo = "[SOReportNo] like '*'"
        Else
            strSOReportNo = "[SOReportNo] = '" & Me.cboSOReportNo & "'"
        End If
    
    
    
    
        If IsNull(Me.cboStatus) Then
            strStaName = "[StatusName] like '*'"
        Else
            strStaName = "[StatusName] = '" & Me.cboStatus & "'"
        End If
    
    
        If IsNull(Me.cboType) Then
            strTypeID = "[TypeID] like '*'"
        Else
            strTypeID = "[TypeID] = " & Me.cboType
        End If
        
        
         If IsNull(Me.cboActionDate) Then
            strActDate = "[ActionDate] like '*'"
        Else
            strActDate = "[ActionDate] = #" & Format(Me.cboActionDate, "mm\/dd\/yyyy") & "#"
        End If
        
        If IsNull(Me.cboActionfDate) Or IsNull(Me.cboActiontDate) Then
            'strActfDate = "[ActionDate] like '*'"
            strActfDate = "[ActionDate] = #" & Format(Me.cboActiontDate, "mm\/dd\/yyyy") & "#"
            strActtDate = "[ActionDate] like '*'"
            strActftDate = "[ActionDate] like '*'"
        Else
            strActftDate = "[ActionDate] BETWEEN #" & Format(Me.cboActionfDate, "mm\/dd\/yyyy") & "# AND #" & Format(Me.cboActiontDate, "mm\/dd\/yyyy") & "#"
        End If
        
        
        If IsNull(Me.cboSalesOrg) Then
            strSalesOrg = "[SOrgID] like '*'"
        Else
            strSalesOrg = "[SOrgID] = " & Me.cboSalesOrg
        End If
        
        'myString = "[ReportID]"
          
        'strActDate & " AND " &
        
        strCriteria = strSOReportNo & " AND " & strStaName & " AND " & strTypeID & " AND " & _
                     strActDate & " AND " & strSalesOrg & " AND " & strActftDate
            task = "SELECT * FROM tblReport WHERE " & strCriteria & " ORDER BY " & myString
            Me.subfrmReport.Form.RecordSource = task
            Me.subfrmReport.Form.Requery
            
        
    
    
    End Function

    Do I need to create a query after each afterupdate from each filter?

    I really have no idea what to do next...

    If someone can help me, that will be great.

    P.S.: The code was taken from austin72406, https://www.youtube.com/watch?v=choPri7y_o4

    Unfortunately the filters are not updated in his video...


    Ideas?

  5. #20
    Susy is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    134
    Should I start a new thread?

  6. #21
    Susy is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    134
    My date format problem is solved...

    Thread is solved!

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 11-20-2018, 11:57 PM
  2. Replies: 5
    Last Post: 09-02-2015, 11:39 AM
  3. Replies: 3
    Last Post: 08-21-2012, 03:05 PM
  4. Parameter Date - Force a Monday Date
    By ker9 in forum Queries
    Replies: 3
    Last Post: 07-26-2011, 01:06 PM
  5. Replies: 1
    Last Post: 07-07-2010, 04:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums