Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6320271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:56:30+00:00 2026-05-24T15:56:30+00:00

What I have is a form which shows company information and also multiple contact

  • 0

What I have is a form which shows company information and also multiple contact subform that shows contact information, seperated by what the contacts job responsibility is(tabbed).

I have a combo box on the company form which displays the job responsibilities, and once a responsibility is selected it will show only company records with a contact of the selected responsibility. This is the code;

Sub SetFilter()

Dim ASQL As String

If IsNull(Me.cboshowcat) Then
' If the combo and all check boxes are Null, use the whole table as the RecordSource.
Me.RecordSource = "SELECT company.* FROM company"

Else

ASQL = "SELECT company.* FROM company INNER JOIN Contacts ON company.company_id = Contacts.company_id WHERE Contacts.responsibility= '" & cboshowcat & "'"
Form_Startup.RecordSource = ASQL

End If

End Sub

The company table will then only show records with a contact of the type specified in the cboshowcat combo box, without showing duplicate companies on the main form.

I then want to apply some further filters based on check boxes on the main form, which relate to fields on the contacts subform. These are activated by a button along with the recordsource code from above;

Private Sub Command201_Click()

If Nz(Me.cboshowcat) = "" And Me.Check194 = True Or Nz(Me.cboshowcat) = "" And Me.Check199 = True Or Nz(Me.cboshowcat) = "" And Me.Check205 = True Then
    MsgBox "Please Select a Job Responsibility"
    Cancel = True
Else

SetFilter
If Me.Check194 = True Then
Me.Filter = "cedit <=Date()-90"
Me.FilterOn = True
Else
Me.Filter = ""
Me.FilterOn = False
If Me.Check199 = True Then
Me.Filter = "((copt)='No')"
Me.FilterOn = True
Else
Me.Filter = ""
Me.FilterOn = False
If Me.Check205 = True Then
Me.Filter = "exsite is null"
Me.FilterOn = True
Else
Me.Filter = ""
Me.FilterOn = False
End If
End If
End If
End If

End Sub

At the moment the button filters out the selected contacts by category but if more than 1 of the checkboxes are checked it only uses one of the filters. How do I make it use multiple filters combined depending which tick box is ticked?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T15:56:31+00:00Added an answer on May 24, 2026 at 3:56 pm

    If you want to filter on multiple criteria then you need to construct the Filter string value to reflect that. Eg:

    Me.Filter = "cedit <=Date()-90 AND exsite is null"
    

    Start with an empty string and go through the checkboxes, building the string as appropriate: if at the end of that process there’s a filter string, apply it.

    Here’s a suggestion on how to do this efficiently:

    Dim sFilter as String
    sFilter=""
    
    '...
    If Me.Check194 Then BuildFilter sFilter, "cedit <=Date()-90" 
    If Me.Check205 Then BuildFilter sFilter, "exsite is null"
    If Me.Check199 Then BuildFilter sFilter, "((copt)='No')" 
    '... more checkboxes...
    
    
    Me.FilterOn = Len(sFilter)>0
    Me.Filter = sFilter
    '....
    
    
    Sub BuildFilter(byRef sFilt as string, sAdd as string)
       If len(sFilt)>0 Then sFilt = sFilt & " AND "
       sFilt = sFilt & sAdd
    End sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form which displays companies and a subform which displays contacts. There
On my Contact#new form I have a drop down which gets all the company
I'm developing a site using the CakePHP framework. I have a form which shows
I have this simple form which shows a pop up calendar when clicked on
I have a form which lets you add names to the table and shows
I have a radMenu on the main site.master form which shows on a page.
Using Rails 3.0.7. I have a simple form which shows all records from one
I have a Company which has one Subscription. Now I want a form to
I have a form to add contacts into a database, which has a select
I have a PHP form which shows one 'User details' block by default. 'User

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.