Results 1 to 8 of 8
  1. #1
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481

    Combo Box Auto Filtering @ Form Load to filter SubForm!

    Hi,



    I have a main form with combo box "CboMonth" with sub continuous form to filter the related monthly results.

    I used this code for similar criteria for another form where to filter the yearly results and this code worked fantastically but in case of months (Months Format is 10-2018, etc) , its not.

    Code:
    
    Private Sub Form_Load()
    Me.CboYear.Value = CLng(Me.CboYear.Column(0, 0))
    
    
    End Sub
    And used for monthly form as below:

    Code:
    Private Sub Form_Load()
    Me.CboMonth.Value = CLng(Me.CboMonth.Column(0, 0))
    
    
    End Sub
    and giving Run Time Error "13" mismatch type.


    Seems something related to the month formats, or else?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Value is default property of data controls, don't have to type it.

    Why are you using CLng() function?

    "10-2018" is a string. CLng() errors on strings.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    In addition,
    There is only one argument for combobox.column()
    so try me.cboYear.column(0)
    Column 0 is the default so just
    me.cboYear
    might be OK

  4. #4
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Hi

    Thanks for feedback.

    I tried this below code for monthly Auto filtering but does not show any effects. *Again have to select the latest month to filter results.


    Me.CboMonth.Value = Me.CboMonth.Column(0)

  5. #5
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Hi

    There was no such a deep idea about to use Clng, just found this code from web and used for year filtering and worked good so copy to monthly period but did not work.

  6. #6
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Any further advise or solution is monthly filtering is not work in format of 10-2018, etc.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    If the method works for one should work for other.

    If you want to provide db ...
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    cap.zadi is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Hi

    Thanks. Let me try otherwise shall the copy of DB.

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

Similar Threads

  1. Replies: 11
    Last Post: 02-08-2018, 04:04 AM
  2. Replies: 11
    Last Post: 05-10-2016, 06:07 PM
  3. Replies: 7
    Last Post: 09-19-2015, 03:14 PM
  4. Replies: 9
    Last Post: 07-03-2014, 12:00 PM
  5. Replies: 0
    Last Post: 08-17-2008, 12:19 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