Results 1 to 8 of 8
  1. #1
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    828

    Filter form with currency and date betweens problems

    TestFilterSerch.zip

    Good Evening All,
    I have attached a sample db (above).
    This is my final search form for my db.... thank the heavens.
    I have two problems which i have not been able to solve and would appriciate some assistance in obtaining a solution.
    There is one form Form2, sample data, and all filters work well except my two problems.

    First Problem:
    The FilterTransAmount is currency data type and not real clear on how to filter that.

    Second Problem:
    I Have a field in tbl/qry called TransDate and that is the date of transaction.


    On form I have two filters (BeginDate and EndDate)
    So, what i am trying to accomplish here is when i put a date in FilterBeginDate it starts filtering from that date (Shhow all Records from that date on) and
    when i put a Date in the FilterEnd Date it would filter form list to be between BeginDate and End Date (Showing records between Begin and End).

    I know this is a lot to ask but would appriciate some assistance with this.
    Thanks
    Dave

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    for the dates:
    Code:
       'check FilterBeginDate
        Forms!form2.FilterBeginDate.SetFocus
        If Len(Forms!form2.FilterBeginDate.Text) & "" > 0 Then
          strWhere = strWhere & "([TransDate] >= #" & Forms!form2.FilterBeginDate.Text & "#) And "
        End If
    
    
       'check FilterEndDate
        Forms!form2.FilterEndDate.SetFocus
        If Len(Forms!form2.FilterEndDate.Text) & "" > 0 Then
          strWhere = strWhere & "([TransDate] <= #" & Forms!form2.FilterEndDate.Text & "#) And "
        End If
    for the currency, I don't know what LIKE $20.00 is. Is it like $22 ? or $2200.00 ? Numbers should be = , not LIKE

    Code:
       'check FilterTransAmount
        Forms!form2.FilterTransAmount.SetFocus
        If Len(Forms!form2.FilterTransAmount.Text) & "" > 0 Then
          strWhere = strWhere & "([TransAmount] =" & CCur(Forms!form2.FilterTransAmount.Text) & ") And "
        End If
    and for all the events in the search controls, don't use on_change, use after_update and forget the cursor positioning:

    Code:
    Private Sub cboFilterTransMethod_afterupdate()
        Call tListBoxFilter
    End Sub
    
    
    Private Sub CboFilterToAccount_afterupdate()
        Call tListBoxFilter
    End Sub
    
    
    Private Sub cboFilterFromAccount_afterupdate()
        Call tListBoxFilter
    End Sub
    
    
    Private Sub FilterEndDate_afterupdate()
        Call tListBoxFilter
         
    '    Me.FilterEndDate.SetFocus
    '    With Me.FilterEndDate
    '        .SelStart = Len(.Text)
    '    End With
    End Sub
    
    
    Private Sub FilterTransCode_afterupdate()
        Call tListBoxFilter
            
    '    Me.FilterTransCode.SetFocus
    '    With Me.FilterTransCode
    '        .SelStart = Len(.Text)
    '    End With
    
    
    End Sub
    
    
    Private Sub FilterBeginDate_afterupdate()
        Call tListBoxFilter
         
    '    Me.FilterBeginDate.SetFocus
    '    With Me.FilterBeginDate
    '        .SelStart = Len(.Text)
    '    End With
    End Sub
    
    
    Private Sub FilterTransAmount_afterupdate()
        Call tListBoxFilter
         
    '    Me.FilterTransAmount.SetFocus
    '    With Me.FilterTransAmount
    '        .SelStart = Len(.Text)
    '    End With
    End Sub
    Last edited by davegri; 12-16-2021 at 09:55 PM. Reason: added currency, color

  3. #3
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    828
    Hi davegri,
    First thank you for taking your time with this.
    I attached the change you gave me and the resutls are as follows.

    Trans Amunt once entered and you leave field, it filters to no records.
    Example if I enter 5000 the list box goes blank.

    Second, the date fields do work one at a time but not between if that makes sense?
    And if you select dates begin and end, list box goes blank also.

    Definately getting closer....

    TestFilterSerch (2).zip

    Thanks
    Dave

  4. #4
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    828
    Hi davegri
    That fixed the currency issue, just dates....
    Thanks
    Dave

  5. #5
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    828
    Thaks so much davegri,
    This works so nicely now... made changes to date and cur
    You are just a wonderful person...
    Merry Christmas
    Dave

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    Quote Originally Posted by d9pierce1 View Post
    Hi davegri,
    First thank you for taking your time with this.
    I attached the change you gave me and the resutls are as follows.

    Trans Amunt once entered and you leave field, it filters to no records.
    Example if I enter 5000 the list box goes blank.

    Second, the date fields do work one at a time but not between if that makes sense?
    And if you select dates begin and end, list box goes blank also.

    Definately getting closer....

    TestFilterSerch (2).zip

    Thanks
    Dave
    You didn't incorporate any of the code changes in module1 that I indicated in post#2 for dates or currency.

  7. #7
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    Ah OK, our posts crossed each other. Glad it's working now.

  8. #8
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    828
    Thank you so much davegri
    This saved me so much time as I had no idea where to even start searching for this.
    Youre fantastic
    Dave

    ps...will mark as solved

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Need to filter records by a currency field range
    By Kipandrews06 in forum Forms
    Replies: 2
    Last Post: 11-10-2021, 12:46 PM
  2. Replies: 4
    Last Post: 06-26-2017, 12:41 PM
  3. Replies: 11
    Last Post: 06-28-2015, 06:42 PM
  4. Problems with Currency Datatype
    By Perceptus in forum Programming
    Replies: 6
    Last Post: 03-27-2014, 02:28 PM
  5. Replies: 1
    Last Post: 11-12-2010, 08:14 AM

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