button to filter form based on selection in form

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

Guest

I have a form that sales reps enter contact information into such as contacts
name, company name, the sales reps select their name from a drop down list to
assign the contact to them. I want automate a filter by selection feature so
they can select their name on a blank record press the button and return only
their contacts. How should I go about doing this?

Thanks in advance
 
try adding the following code to the command button's Click event procedure,
as

Me.Filter = "SalesRepIDFieldName = " & Me!ComboBoxName
Me.FilterOn = True

substitute the correct field name, and control name.

hth
 
Thanks Tina appreciate the quick response!

Maybe you could help me with another problem. I set it up so that when
they select their name in the form, filter by selection takes effect. How do
I set it up so that if they need to change the selected name to another name
(in case they need to get info from another sales reps contacts) the filter
is removed then reapplied with the new selection. I have it so I can filter
by selection now but if i try to change the name the filter isn't lifted
allowing the new selection to go back and filter through all the records
again.
 
try

Me.FilterOn = False
Me.Filter = "SalesRepIDFieldName = " & Me!ComboBoxName
Me.FilterOn = True

hth
 
Ok....none of that ended up working. I think I am not explaining what I want
to happen correctly. One more go at it before I check myself into the
looney bin.
I want the sales rep to open access......they get a switchboard that
gives them choices to either just enter a new record or view their records.
They choose to view their records and upon clicking on the switchboard button
the normal form they see to enter information into displays (I know this is a
different form but they don't). They then select their name from the drop
down list (just like they would if they were adding a new contact's
information) WHAM unbeknownst to them the table with every contacts info has
now been filtered by selection and they can navigate through their contacts.
I have gotten this far using the AfterUpdate property event procedure.
Now say he needs to view another sales reps contacts. He just wants to
select the other sales reps name from the form in front of his face and have
an entirely new filter placed on all the records. This is where my problem
lies. During my testing I select the first sales reps name and the filter
works fine. If I then attempt to select a different name the filter runs but
not based on all the records just the filtered ones from the first selection.
It's like a filter within a filter. I am not sure how to tell it to remove
the existing filter so the new selection will be run against all the records.

Does this make any sense? How would the best way to go about it be? If I am
doing it wrong let me know I am very new to Access.

Thanks
 
i tested my solution, using an unbound combo box in the form's Header
section, and it worked. but if i understand you correctly, your user is
actually changing the name of the sales rep in either a new blank record, or
possibly in an existing record, and then clicking the command button to
filter the form.

if that's the case, then i assume you do not want the sales rep change to be
actually saved into the current record. the following might work for you, as

Dim varID As Variant

varID = Me!SalesRepIDFieldName
Me.Undo

Me.FilterOn = False
Me.Filter = "SalesRepIDFieldName = " & varID
Me.FilterOn = True

hth
 
Back
Top