Results 1 to 3 of 3
  1. #1
    Alhassani is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    53

    Combobox subform filter: text field vs. number field

    I have VBA tied to the afterupdate event on a combo box that filters various subforms on a form. I have a weekly form and a monthly form. The weekly form is filtering based on a number field and works perfectly. The monthly form is trying to filter the exact same way but using a text field. Obviously, this is not working at all. When I select a month from the combo box, it asks me for the parameter value for that month. If I type in the month the filter works, if not then it doesn't. How do I change the vba below to accurately look at text instead of numbers? Thanks.

    Code:
    Private Sub cmbmonth_AfterUpdate()
    On Error GoTo Proc_Error
    DoCmd.SetWarnings False
    If IsNull(Me.cmbmonth) Then
       Me.Monthly_Scores_RM_subform.Form.Filter = ""
       Me.Monthly_Scores_RM_subform.Form.FilterOn = False
    Else
      Me.Monthly_Scores_RM_subform.Form.Filter = "[Audit_Month]=" & Me.cmbmonth
      Me.Monthly_Scores_RM_subform.Form.FilterOn = True
    End If
    DoCmd.SetWarnings True
    Proc_Exit:
       Exit Sub
    Proc_Error:
       MsgBox "Error " & Err.Number & " in setting subform filter:" & vbCrLf & Err.Description
       Resume Proc_Exit
    End Sub


  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Based on what you have said, the problem is your SQL that generate the combo box. What is in the "Row Source" in the property?

  3. #3
    Missinglinq's Avatar
    Missinglinq is online now VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The syntax for a Text Field would be

    "[Audit_Month]='" & Me.cmbmonth & "'"

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 2
    Last Post: 03-30-2012, 07:39 AM
  2. Replies: 1
    Last Post: 09-06-2011, 01:47 PM
  3. Replies: 29
    Last Post: 08-16-2011, 05:52 PM
  4. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  5. Replies: 0
    Last Post: 12-16-2009, 01:14 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