Results 1 to 8 of 8
  1. #1
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    216

    Filter produces a blank form

    I have a form which contains all the companies we work for. It has a combo box named cboFilterCompany which I am trying to use to filter the company ID field (a text box named tbLngCompanyNamesID)

    The cboFilterCompany has the RowSource as:
    "SELECT DISTINCT tblSpecialBillingCompanies.fTxtCompany, tblSpecialBillingCompanies.fLngCompanyNamesID
    FROM tblSpecialBillingCompanies
    WHERE (((tblSpecialBillingCompanies.fTxtCompany) Is Not Null))
    ORDER BY tblSpecialBillingCompanies.fTxtCompany;"
    which creates 2 columns, fTxtCompany and fLngCompanyNamesID. The BoundColumn is set on 2.

    The AfterUpdate event is:
    Private Sub cboFilterCompany_AfterUpdate()
    If Nz(cboFilterCompany, 0) > 0 Then
    Me.Filter = "[tbLngCompanyNamesID] = " & cboFilterCompany
    Me.FilterOn = True
    Else
    MsgBox "ID is missing"
    End If
    End Sub



    It seems to work. At the bottom, it shows 'Record 1 of 1' and that it is filtered. It even shows "[tbLngCompanyNamesID] = 10" in the filter on the form. But it don't show a record. The form is blank when filtered. I have tried it on several different companies and all are the same. I will appreaciate any help.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I believe that if it shows one record then there is a record there. Are you dealing with a main form and subform? Is the combo bound?

  3. #3
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    216
    The combo box is unbound and it is on the main form. And I am trying to filter the main form. It does show 'Record 1 of 1' each time I filter it, but it is a blank record. I know the records are in the table.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Maybe

    If Nz(cboFilterCompany.Column(1), 0) > 0 Then

    The value of your combo may be equal to the text and not the ID number you are trying to match in your criteria

    you could do something like this within your afterupdate to help you visualize

    debug.print "First Column = " & cboFilterCompany.column(0)
    debug.print "Second Column = " & cboFilterCompany.column(1)

  5. #5
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    216
    The results was:
    First Column = American Assembly
    Second Column = 102

    Keep in mind, the filter on the form shows [tbLngCompanyNamesID] = 102

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I would build a new form and a new combobox. Create a combobox without the wizard and paste you SQL into the RowSource. Set the properties for Combo, such as Width, Bound, Name, etc. You can paste this stuff.

    Bind the form or subform to the table and add the ID field to the bound form. Paste you VBA in the afterupdate and see what you get. Strip it down simple and build from there.

  7. #7
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    216
    Ok, I have created a new simple form with only CompanyName and CimpanyID fields and a combo box. The filter works good. There is something else wrong with my original form. Thank you for your help. I am closing this. Thanks again

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by lawdy View Post
    .... There is something else wrong with my original form. ...
    There is something wrong. It may be a good idea to rebuild it entirely, carefully pasting the VBA into new sub procedures.

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

Similar Threads

  1. Replies: 12
    Last Post: 10-31-2013, 02:35 AM
  2. Replies: 1
    Last Post: 03-22-2013, 09:59 AM
  3. Changing Printers Code produces an error
    By Perceptus in forum Programming
    Replies: 4
    Last Post: 01-15-2013, 08:33 PM
  4. Replies: 5
    Last Post: 07-26-2009, 12:13 PM
  5. exporting text produces a number
    By greend in forum Import/Export Data
    Replies: 0
    Last Post: 07-12-2006, 03:55 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