Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2003
    Location
    UK
    Posts
    85

    Red face Unanswered: Problem with data filter on form with combo

    Dear All

    I want to filter records at the click of a button on my form based on the selection I make in an unbound combo box placed on same form.

    I am using following codes. Can someone please let me know where I am doing wrong.

    Private Sub Command22_Click()
    'Filter data for CustomerID
    Dim myInt As String
    If IsNull(Forms![Main Form]![cboCustomer]) Then
    DisplayMessage ("Please select Customer first")

    Else
    myInt = [Forms]![Main Form]![cboCustomer]
    Me.Filter = "MainTable.[Customer ID] = 'myInt'"
    Me.FilterOn = True
    End If
    End Sub

    Thanks

  2. #2
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    Quote Originally Posted by dbase
    Me.Filter = "MainTable.[Customer ID] = 'myInt'"
    You should change that line this one:
    Me.Filter = "MainTable.[Customer ID] =" & CStr(myInt)

    You have to convert myInt variable to string with CStr() function before use it with the filter.
    ghozy.

  3. #3
    Join Date
    Nov 2003
    Posts
    1,487
    Me.Filter = "MainTable.[Customer ID] = '" & myInt & "'"



  4. #4
    Join Date
    Mar 2003
    Location
    UK
    Posts
    85
    Thank you very much for your reply.

    I will try it out and let you know.

    Thanks

Posting Permissions

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