Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2007

Tip: Looking for answers? Try searching our database.

Combo Box to Filter Form Records

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bjohnson3132 - 19 Jan 2007 00:23 GMT
Hi,

I am a novice at this so I hope this makes sense.  I am trying to apply a
filter to an unbound combo box within the main form 'ArcView_Users' that will
allow me to select a value and filter out only those records in the main form
that contain that value.  The values in the combo come from subform 'Classes'
using this SQL statement in the Row Source of the combo;

Row Source Type - Table/Query
Row Source - SELECT DISTINCT [Classes.CLASS] FROM [Classes] ORDER BY [Classes.
CLASS];
'Which gives me only the unique text values from the Classes' table CLASS
field'

The underlying query for the combo is called-
ClassType
 

What SQL statement or VBA code do I need to add in order to get the records I
need in the Form based on the value I select in the combo box?  Any help
would be appreciated.  

Thanks,

Brian
Marshall Barton - 19 Jan 2007 06:28 GMT
>I am a novice at this so I hope this makes sense.  I am trying to apply a
>filter to an unbound combo box within the main form 'ArcView_Users' that will
[quoted text clipped - 14 lines]
>need in the Form based on the value I select in the combo box?  Any help
>would be appreciated.  

You could construct the form's record source SQL statement,
probably in the combo box's AfterUpdate event proceure:

Dim strSQL As String
strSQL = "SELECT * FROM maintable  " & _
        "WHERE somefield = " & Me.thecomboboxname & _
        "  ORDER BY whatever"
Me.RecordSource = strSQL

Or, you could modify the main form's record source query to
use the criteria:

Forms!ArcView_Users.thecomboboxname

and then just use:

Me.Requery in the AfterUpdate event.

Another way is to set the main form's Filter property, but I
do not recommend this because it interacts with any subforms
in very strange ways.

Signature

Marsh
MVP [MS Access]

deeds - 23 Mar 2007 04:53 GMT
Hello...I used your code for 2 combo boxes for filter:

Forms!ArcView_Users.thecomboboxname
and then just use:
Me.Requery in the AfterUpdate event.

This works for both of my combo boxes when selections are made...however,
when just one is selected it does not return data.  I put the code in for
both fields that I want to filter on.  Bottom line is I want to be able to
filter using 1 or both combo boxes as the criteria...any thoughts?  Thanks.

> >I am a novice at this so I hope this makes sense.  I am trying to apply a
> >filter to an unbound combo box within the main form 'ArcView_Users' that will
[quoted text clipped - 36 lines]
> do not recommend this because it interacts with any subforms
> in very strange ways.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.