mutley1
MIS
- Jul 24, 2003
- 909
I am trying to get a 2 drop down combo boxes in a form header to filter the detail in the form, but every time I select the value from the first it is fine, but when I select the 2nd it wipes out the filter from the first. Example data:
Table being used for detail is called "Clm837PQualifier", fields are:
Q_Loop
Q_Segment
Q_Qualifier
Q_Description
1 Loop can have several segments
Segments can appear in more than 1 loop, e.g.
Loop Segment
A Name
A Date
B Name
B Address
B Color
B Date
Each Loop segment may have several qualifiers, but that isn't the problem - the filtering is. 2 combo drop down boxes are LoopDD and SegmentDD.
I have values in LoopDD (distinct Loop from qualifier) - Fine
I have values in Segment DD (distinct segment from qualifier) - Fine.
I have a query in the "on click" of LoopDD so that once the loop is chosen (requery SegmentDD in the macro),
the SegmentDD box offers only those segments relevant to the loop - Fine.
Problem is:
1. I click on LoopDD and select A - this filters the detail to Loop A and relevant Segments (Name and Date) in the detail, and the only 2 options in the SegmentDD box are now Name and Date (as they are the 2 linked to Loop A).
2. I click on Date in the SegmentDD box and it clears the first filter from the macro on the LoopDD box and filters only on Date, so the detail now shows Loop A, Date and any qualifiers relevant, AND Loop B, Date segments and qualifiers.
How do I get it to filter by Loop, OR segment, OR preferably by both without wiping out the previous filter.
Loop Macro is:
Conditions Action Argument
Requery SegmentDD
[Forms]![Clm837PQualifier]![LoopDD] Is Null RunCommand RemoveFilterSort
… SetCommand cmdShowAll, Enabled, 0
… StopAllMacros
SetTempVar strSearch, Replace([Forms]![Clm837PQualifier]![LoopDD],"""","""""")
SetTempVar strFilter, "([Q_Loop] Like ""*" & [TempVars]![strSearch] & "*"")"
ApplyFilter , =[TempVars]![strFilter],
RemoveTempVar strFilter
RemoveTempVar strSearch
Segment Macro is:
Conditions Action Argument
[Forms]![Clm837PQualifier]![SegmentDD] Is Null RunCommand RemoveFilterSort
… SetCommand cmdShowAll, Enabled, 0
… StopAllMacros
SetTempVar strSearch, Replace([Forms]![Clm837PQualifier]![SegmentDD],"""","""""")
SetTempVar strFilter, "([Q_Segment] Like ""*" & [TempVars]![strSearch] & "*"")"
ApplyFilter , =[TempVars]![strFilter],
RemoveTempVar strFilter
RemoveTempVar strSearch
I have tried using a strSearch2, strFilter2 in the one macro so that there are kinda 2, 1 strSearch / filter on the Loop and 1 for the segment, but it doesn't want to play.
Please - any help appreciated for an Ex-SQL guy who is decidedly rubbish with Access.
Table being used for detail is called "Clm837PQualifier", fields are:
Q_Loop
Q_Segment
Q_Qualifier
Q_Description
1 Loop can have several segments
Segments can appear in more than 1 loop, e.g.
Loop Segment
A Name
A Date
B Name
B Address
B Color
B Date
Each Loop segment may have several qualifiers, but that isn't the problem - the filtering is. 2 combo drop down boxes are LoopDD and SegmentDD.
I have values in LoopDD (distinct Loop from qualifier) - Fine
I have values in Segment DD (distinct segment from qualifier) - Fine.
I have a query in the "on click" of LoopDD so that once the loop is chosen (requery SegmentDD in the macro),
the SegmentDD box offers only those segments relevant to the loop - Fine.
Problem is:
1. I click on LoopDD and select A - this filters the detail to Loop A and relevant Segments (Name and Date) in the detail, and the only 2 options in the SegmentDD box are now Name and Date (as they are the 2 linked to Loop A).
2. I click on Date in the SegmentDD box and it clears the first filter from the macro on the LoopDD box and filters only on Date, so the detail now shows Loop A, Date and any qualifiers relevant, AND Loop B, Date segments and qualifiers.
How do I get it to filter by Loop, OR segment, OR preferably by both without wiping out the previous filter.
Loop Macro is:
Conditions Action Argument
Requery SegmentDD
[Forms]![Clm837PQualifier]![LoopDD] Is Null RunCommand RemoveFilterSort
… SetCommand cmdShowAll, Enabled, 0
… StopAllMacros
SetTempVar strSearch, Replace([Forms]![Clm837PQualifier]![LoopDD],"""","""""")
SetTempVar strFilter, "([Q_Loop] Like ""*" & [TempVars]![strSearch] & "*"")"
ApplyFilter , =[TempVars]![strFilter],
RemoveTempVar strFilter
RemoveTempVar strSearch
Segment Macro is:
Conditions Action Argument
[Forms]![Clm837PQualifier]![SegmentDD] Is Null RunCommand RemoveFilterSort
… SetCommand cmdShowAll, Enabled, 0
… StopAllMacros
SetTempVar strSearch, Replace([Forms]![Clm837PQualifier]![SegmentDD],"""","""""")
SetTempVar strFilter, "([Q_Segment] Like ""*" & [TempVars]![strSearch] & "*"")"
ApplyFilter , =[TempVars]![strFilter],
RemoveTempVar strFilter
RemoveTempVar strSearch
I have tried using a strSearch2, strFilter2 in the one macro so that there are kinda 2, 1 strSearch / filter on the Loop and 1 for the segment, but it doesn't want to play.
Please - any help appreciated for an Ex-SQL guy who is decidedly rubbish with Access.