Filter using multiple combo box

L

Lou

I have a for that I have 3 combo boxes [projects],
[engineer],[completedate] what I want is to select the
[project] and then select the [engineer] from those
results and then month [completedate]. If someone could
direct me to where I maybe able to find some code to make
this happen..
Thanks in advance..
 
E

Eric Butts [MSFT]

Hi Lou,

See:
ACC2000: How to Synchronize Two Combo Boxes on a Form (209595)
http://support.microsoft.com/default.aspx?scid=KB;EN-US;209595

I hope this helps! If you have additional questions on this topic, please
respond back to this posting.


Regards,

Eric Butts
Microsoft Access Support
(e-mail address removed)
"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
<http://www.microsoft.com/security/security_bulletins/ms03-026.asp> and/or
to visit Windows Update at <http://windowsupdate.microsoft.com/> to install
the patch. Running the SCAN program from the Windows Update site will help
to insure you are current with all security patches, not just MS03-026."

This posting is provided "AS IS" with no warranties, and confers no rights


--------------------
| Content-Class: urn:content-classes:message
| From: "Lou" <[email protected]>
| Sender: "Lou" <[email protected]>
| Subject: Filter using multiple combo box
| Date: Mon, 16 Aug 2004 12:26:24 -0700
| Lines: 8
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcSDxurwQ3DVa6NWS8my/Huq1cbBnA==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.access.formscoding
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.access.formscoding:242354
| NNTP-Posting-Host: tk2msftngxa12.phx.gbl 10.40.1.164
| X-Tomcat-NG: microsoft.public.access.formscoding
|
| I have a for that I have 3 combo boxes [projects],
| [engineer],[completedate] what I want is to select the
| [project] and then select the [engineer] from those
| results and then month [completedate]. If someone could
| direct me to where I maybe able to find some code to make
| this happen..
| Thanks in advance..
|
|
 
L

Lou

Eric,
Thank you for the suggestion, I tried this but it is not
what I am exactly looking for. The code below is what I
am working with now. The problem that I have run into
with this code is when I filter by [project] and then try
to sort by the next combo box [engineer] it sort all the
records and not just by the results of the [project]
sort.
I found this code in the newsgroup sometime ago and I am
not able to find it again. I remember the creator saying
that you should be able to use multi fields to sort by,
but I have had no luck.
Thanks again Lou
Dim strWhere As String
Dim lngLen As Long
Me.Refresh
If Me.Dirty Then 'Save before filter
Me.Dirty = False
End If

If Not IsNull(Me.cmbprojectsort) Then
strWhere = strWhere & "([project_name] = """ & _
Me.cmbprojectsort & """) AND "
End If

If Not IsNull(Me.cmbcontactsort) Then
strWhere = strWhere & "([vwcontact] = """ & _
Me.cmbcontactsort & """) AND "
End If

'etc for other search boxes.

lngLen = Len(strWhere) - 5 'Without trailing "
AND ".
If lngLen <= 0 Then
MsgBox "No criteria."
Else
Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True

End If
 
E

Eric Butts [MSFT]

Hi Lou,

What this sample code attempts to do is to Filter the Form based on
selection of Combo boxes:

Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True

An example of what would happen is
- Form based on 100 records
- User selects value in combo box [projects]
- User selects value in combo box [engineer]
- User selects value in combo box [completedate]
- Based on what was selected Form now displays 35 records

Is that what you are attempting?

Regards,

Eric Butts
Microsoft Access Support
(e-mail address removed)
"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
<http://www.microsoft.com/security/security_bulletins/ms03-026.asp> and/or
to visit Windows Update at <http://windowsupdate.microsoft.com/> to install
the patch. Running the SCAN program from the Windows Update site will help
to insure you are current with all security patches, not just MS03-026."

This posting is provided "AS IS" with no warranties, and confers no rights


--------------------
| Content-Class: urn:content-classes:message
| From: "Lou" <[email protected]>
| Sender: "Lou" <[email protected]>
| References: <[email protected]>
<#W#P#x#[email protected]>
| Subject: RE: Filter using multiple combo box
| Date: Tue, 17 Aug 2004 06:33:46 -0700
| Lines: 42
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcSEXtJWGpYi3XRXT4KjC/RGGU+hwA==
| Newsgroups: microsoft.public.access.formscoding
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.access.formscoding:242434
| NNTP-Posting-Host: tk2msftngxa13.phx.gbl 10.40.1.165
| X-Tomcat-NG: microsoft.public.access.formscoding
|
| Eric,
| Thank you for the suggestion, I tried this but it is not
| what I am exactly looking for. The code below is what I
| am working with now. The problem that I have run into
| with this code is when I filter by [project] and then try
| to sort by the next combo box [engineer] it sort all the
| records and not just by the results of the [project]
| sort.
| I found this code in the newsgroup sometime ago and I am
| not able to find it again. I remember the creator saying
| that you should be able to use multi fields to sort by,
| but I have had no luck.
| Thanks again Lou
| Dim strWhere As String
| Dim lngLen As Long
| Me.Refresh
| If Me.Dirty Then 'Save before filter
| Me.Dirty = False
| End If
|
| If Not IsNull(Me.cmbprojectsort) Then
| strWhere = strWhere & "([project_name] = """ & _
| Me.cmbprojectsort & """) AND "
| End If
|
| If Not IsNull(Me.cmbcontactsort) Then
| strWhere = strWhere & "([vwcontact] = """ & _
| Me.cmbcontactsort & """) AND "
| End If
|
| 'etc for other search boxes.
|
| lngLen = Len(strWhere) - 5 'Without trailing "
| AND ".
| If lngLen <= 0 Then
| MsgBox "No criteria."
| Else
| Me.Filter = Left(strWhere, lngLen)
| Me.FilterOn = True
|
| End If
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top