Filtering a form with Combobox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form [frmProjects] with on field being [Project Manager]

I want users to have a drop down combo box, where they would select their
name and then have the form filtered to show only their set pf projects

I have searched this discussion group but I just can't get done.

I can start with an unbound combo box in the header of the form, I got that
part,
but what are my next steps

Your help is appreciated

Jet
 
In the AfterUpdate event of the combobox, ut some code like this:

If Not IsNull(Me.MyCombo) Then
Me.FilterOn = True
Me.Filter = "[Project Manager] ='" & Me.MyCombo & "'"
Else
Me.FilterOn = False
End If

This assumes that the bound column of your combobox is the one that contains
the project manager's name and that the [Project Manager] field also contains
the name.

Barry
 
This worked fine for me, thanks !

Just one point, to initiate a new query, I have to click the Access Filter
In the AfterUpdate event of the combobox, ut some code like this:

If Not IsNull(Me.MyCombo) Then
Me.FilterOn = True
Me.Filter = "[Project Manager] ='" & Me.MyCombo & "'"
Else
Me.FilterOn = False
End If

This assumes that the bound column of your combobox is the one that contains
the project manager's name and that the [Project Manager] field also contains
the name.

Barry

Jet said:
I have a form [frmProjects] with on field being [Project Manager]

I want users to have a drop down combo box, where they would select their
name and then have the form filtered to show only their set pf projects

I have searched this discussion group but I just can't get done.

I can start with an unbound combo box in the header of the form, I got that
part,
but what are my next steps

Your help is appreciated

Jet
 
I'm not sure which filter button you're referring to, maybe the Filter By
Form? In any case, you can perform any button or menu's function by calling
DoCmd.RunCommand

There are constants that you can pass in to this that refer to menu options.
For example:
DoCmd.RunCommand acCmdFilterByForm performs the same function as the Filtyer
By Form button. You just need to put that line of code under a button's
OnClick event.

Barry

Olivier Crouzet said:
This worked fine for me, thanks !

Just one point, to initiate a new query, I have to click the Access Filter
In the AfterUpdate event of the combobox, ut some code like this:

If Not IsNull(Me.MyCombo) Then
Me.FilterOn = True
Me.Filter = "[Project Manager] ='" & Me.MyCombo & "'"
Else
Me.FilterOn = False
End If

This assumes that the bound column of your combobox is the one that contains
the project manager's name and that the [Project Manager] field also contains
the name.

Barry

Jet said:
I have a form [frmProjects] with on field being [Project Manager]

I want users to have a drop down combo box, where they would select their
name and then have the form filtered to show only their set pf projects

I have searched this discussion group but I just can't get done.

I can start with an unbound combo box in the header of the form, I got that
part,
but what are my next steps

Your help is appreciated

Jet
 
I was refering to the Access Apply/Remove Filter Button in the Tab Menu.
Unless I click on it, my cbo won't pass the new query onto the subform.
I'd rather do this with a command on my form, or better, with any
AfterUpdate on the combo box.

Olivier
-------

Barry Gilbert said:
I'm not sure which filter button you're referring to, maybe the Filter By
Form? In any case, you can perform any button or menu's function by calling
DoCmd.RunCommand

There are constants that you can pass in to this that refer to menu options.
For example:
DoCmd.RunCommand acCmdFilterByForm performs the same function as the Filtyer
By Form button. You just need to put that line of code under a button's
OnClick event.

Barry

Olivier Crouzet said:
This worked fine for me, thanks !

Just one point, to initiate a new query, I have to click the Access Filter
In the AfterUpdate event of the combobox, ut some code like this:

If Not IsNull(Me.MyCombo) Then
Me.FilterOn = True
Me.Filter = "[Project Manager] ='" & Me.MyCombo & "'"
Else
Me.FilterOn = False
End If

This assumes that the bound column of your combobox is the one that contains
the project manager's name and that the [Project Manager] field also contains
the name.

Barry

:

I have a form [frmProjects] with on field being [Project Manager]

I want users to have a drop down combo box, where they would select their
name and then have the form filtered to show only their set pf projects

I have searched this discussion group but I just can't get done.

I can start with an unbound combo box in the header of the form, I got that
part,
but what are my next steps

Your help is appreciated

Jet
 
Olivier Crouzet said:
I was refering to the Access Apply/Remove Filter Button in the Tab Menu.
Unless I click on it, my cbo won't pass the new query onto the subform.
I'd rather do this with a command on my form, or better, with any
AfterUpdate on the combo box.

Olivier

DoCmd.RunCommand acCmdApplyFilterSort
and
DoCmd.RunCommand acCmdRemoveFilterSort

are the same as clicking this button. You should be able to put these
statements anywhere that makes sense: under a button click, in a combobox's
AfterUpdate, etc.

Barry
 
Many thanks Barry and Jet !
(Next step : query with more than one combo)
Olivier
-------
 

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

Back
Top