Mr. B,
Sorry, I am still learning SQL and VBA, I don't think that I made the
module correctly. After I added the module none of the sql code
worked. Did I not need to make a module? Was the code supposed to go
somewhere else?
Steve and Karl -
Below is the SQL code that I currently have.
The form contains 5 combo boxes; SBT Account, Region, ADM, Month, Year
I named each of the combo boxes with the same names, just with
"Select" at the end, as you will see in the code.
I can leave all combo boxes blank and retrieve all 33 records, If I
use any one of the combo boxes individually, except for Region, the
query works fine. If I only make a selection in the Region combo box
then the qurey retrieves all 33 records instead of filtering by my
selection.
Thank you all again for the help.
Here is the code, sorry it is very long:
SELECT [ARCHIVE - ADM Summary].ADM, [ARCHIVE - ADM Summary].Region,
[ARCHIVE - ADM Summary].[SBT Account], [ARCHIVE - ADM Summary].Month,
[ARCHIVE - ADM Summary].Year, [ARCHIVE - ADM Summary].[# Of Stores
Counted], [ARCHIVE - ADM Summary].[ADM Cumulative Shrink %]
FROM [ARCHIVE - ADM Summary]
WHERE ((([ARCHIVE - ADM Summary].ADM)=[Forms]![Main Form]![ADM
Select]) AND (([ARCHIVE - ADM Summary].Region)=[Forms]![Main Form]!
[Region Select]) AND (([ARCHIVE - ADM Summary].[SBT Account])=[Forms]!
[Main Form]![SBT Account Select]) AND (([ARCHIVE - ADM Summary].Month)=
[Forms]![Main Form]![Month Select]) AND (([ARCHIVE - ADM Summary].Year)
=[Forms]![Main Form]![Year Select])) OR ((([ARCHIVE - ADM
Summary].Region)=[Forms]![Main Form]![Region Select]) AND (([ARCHIVE -
ADM Summary].[SBT Account])=[Forms]![Main Form]![SBT Account Select])
AND (([ARCHIVE - ADM Summary].Month)=[Forms]![Main Form]![Month
Select]) AND (([ARCHIVE - ADM Summary].Year)=[Forms]![Main Form]![Year
Select]) AND ((IsNull([Forms]![Main Form]![ADM Select]))<>False)) OR
((([ARCHIVE - ADM Summary].ADM)=[Forms]![Main Form]![ADM Select]) AND
(([ARCHIVE - ADM Summary].Region)=[Forms]![Main Form]![Region Select])
AND (([ARCHIVE - ADM Summary].Month)=[Forms]![Main Form]![Month
Select]) AND (([ARCHIVE - ADM Summary].Year)=[Forms]![Main Form]![Year
Select]) AND ((IsNull([Forms]![Main Form]![SBT Account Select]))
<>False)) OR ((([ARCHIVE - ADM Summary].ADM)=[Forms]![Main Form]![ADM
Select]) AND (([ARCHIVE - ADM Summary].Region)=[Forms]![Main Form]!
[Region Select]) AND (([ARCHIVE - ADM Summary].[SBT Account])=[Forms]!
[Main Form]![SBT Account Select]) AND (([ARCHIVE - ADM Summary].Year)=
[Forms]![Main Form]![Year Select]) AND ((IsNull([Forms]![Main Form]!
[Month Select]))<>False)) OR ((([ARCHIVE - ADM Summary].Region)=
[Forms]![Main Form]![Region Select]) AND (([ARCHIVE - ADM Summary].
[SBT Account])=[Forms]![Main Form]![SBT Account Select]) AND
(([ARCHIVE - ADM Summary].Year)=[Forms]![Main Form]![Year Select]) AND
((IsNull([Forms]![Main Form]![ADM Select]))<>False) AND ((IsNull
([Forms]![Main Form]![Month Select]))<>False)) OR ((([ARCHIVE - ADM
Summary].Region)=[Forms]![Main Form]![Region Select]) AND (([ARCHIVE -
ADM Summary].Year)=[Forms]![Main Form]![Year Select]) AND ((IsNull
([Forms]![Main Form]![ADM Select]))<>False) AND ((IsNull([Forms]![Main
Form]![SBT Account Select]))<>False) AND ((IsNull([Forms]![Main Form]!
[Month Select]))<>False)) OR ((([ARCHIVE - ADM Summary].ADM)=[Forms]!
[Main Form]![ADM Select]) AND (([ARCHIVE - ADM Summary].Region)=
[Forms]![Main Form]![Region Select]) AND (([ARCHIVE - ADM Summary].
[SBT Account])=[Forms]![Main Form]![SBT Account Select]) AND
(([ARCHIVE - ADM Summary].Month)=[Forms]![Main Form]![Month Select])
AND ((IsNull([Forms]![Main Form]![Year Select]))<>False)) OR
((([ARCHIVE - ADM Summary].Region)=[Forms]![Main Form]![Region
Select]) AND (([ARCHIVE - ADM Summary].[SBT Account])=[Forms]![Main
Form]![SBT Account Select]) AND (([ARCHIVE - ADM Summary].Month)=
[Forms]![Main Form]![Month Select]) AND ((IsNull([Forms]![Main Form]!
[ADM Select]))<>False) AND ((IsNull([Forms]![Main Form]![Year Select]))
<>False)) OR ((([ARCHIVE - ADM Summary].Region)=[Forms]![Main Form]!
[Region Select]) AND (([ARCHIVE - ADM Summary].Month)=[Forms]![Main
Form]![Month Select]) AND ((IsNull([Forms]![Main Form]![ADM Select]))
<>False) AND ((IsNull([Forms]![Main Form]![SBT Account Select]))
<>False) AND ((IsNull([Forms]![Main Form]![Year Select]))<>False)) OR
((([ARCHIVE - ADM Summary].ADM)=[Forms]![Main Form]![ADM Select]) AND
(([ARCHIVE - ADM Summary].Region)=[Forms]![Main Form]![Region Select])
AND (([ARCHIVE - ADM Summary].[SBT Account])=[Forms]![Main Form]![SBT
Account Select]) AND ((IsNull([Forms]![Main Form]![Month Select]))
<>False) AND ((IsNull([Forms]![Main Form]![Year Select]))<>False)) OR
((([ARCHIVE - ADM Summary].Region)=[Forms]![Main Form]![Region
Select]) AND (([ARCHIVE - ADM Summary].[SBT Account])=[Forms]![Main
Form]![SBT Account Select]) AND ((IsNull([Forms]![Main Form]![ADM
Select]))<>False) AND ((IsNull([Forms]![Main Form]![Month Select]))
<>False) AND ((IsNull([Forms]![Main Form]![Year Select]))<>False)) OR
((([ARCHIVE - ADM Summary].ADM)=[Forms]![Main Form]![ADM Select]) AND
(([ARCHIVE - ADM Summary].Region)=[Forms]![Main Form]![Region Select])
AND ((IsNull([Forms]![Main Form]![SBT Account Select]))<>False) AND
((IsNull([Forms]![Main Form]![Month Select]))<>False) AND ((IsNull
([Forms]![Main Form]![Year Select]))<>False)) OR ((([ARCHIVE - ADM
Summary].Region)=[Forms]![Main Form]![Region Select]) AND (([ARCHIVE -
ADM Summary].Month)=[Forms]![Main Form]![Month Select]) AND (([ARCHIVE
- ADM Summary].Year)=[Forms]![Main Form]![Year Select]) AND ((IsNull
([Forms]![Main Form]![ADM Select]))<>False) AND ((IsNull([Forms]![Main
Form]![SBT Account Select]))<>False)) OR ((([ARCHIVE - ADM
Summary].ADM)=[Forms]![Main Form]![ADM Select]) AND (([ARCHIVE - ADM
Summary].Region)=[Forms]![Main Form]![Region Select]) AND (([ARCHIVE -
ADM Summary].Year)=[Forms]![Main Form]![Year Select]) AND ((IsNull
([Forms]![Main Form]![SBT Account Select]))<>False) AND ((IsNull
([Forms]![Main Form]![Month Select]))<>False)) OR ((([ARCHIVE - ADM
Summary].ADM)=[Forms]![Main Form]![ADM Select]) AND (([ARCHIVE - ADM
Summary].Region)=[Forms]![Main Form]![Region Select]) AND (([ARCHIVE -
ADM Summary].Month)=[Forms]![Main Form]![Month Select]) AND ((IsNull
([Forms]![Main Form]![SBT Account Select]))<>False) AND ((IsNull
([Forms]![Main Form]![Year Select]))<>False)) OR (((IsNull([Forms]!
[Main Form]![ADM Select]))<>False) AND ((IsNull([Forms]![Main Form]!
[SBT Account Select]))<>False) AND ((IsNull([Forms]![Main Form]![Month
Select]))<>False) AND ((IsNull([Forms]![Main Form]![Year Select]))
<>False)) OR ((([ARCHIVE - ADM Summary].ADM)=[Forms]![Main Form]![ADM
Select]) AND (([ARCHIVE - ADM Summary].[SBT Account])=[Forms]![Main
Form]![SBT Account Select]) AND (([ARCHIVE - ADM Summary].Month)=
[Forms]![Main Form]![Month Select]) AND (([ARCHIVE - ADM Summary].Year)
=[Forms]![Main Form]![Year Select]) AND ((IsNull([Forms]![Main Form]!
[Region Select]))<>False)) OR ((([ARCHIVE - ADM Summary].[SBT Account])
=[Forms]![Main Form]![SBT Account Select]) AND (([ARCHIVE - ADM
Summary].Month)=[Forms]![Main Form]![Month Select]) AND (([ARCHIVE -
ADM Summary].Year)=[Forms]![Main Form]![Year Select]) AND ((IsNull
([Forms]![Main Form]![ADM Select]))<>False) AND ((IsNull([Forms]![Main
Form]![Region Select]))<>False)) OR ((([ARCHIVE - ADM Summary].ADM)=
[Forms]![Main Form]![ADM Select]) AND (([ARCHIVE - ADM Summary].Month)=
[Forms]![Main Form]![Month Select]) AND (([ARCHIVE - ADM Summary].Year)
=[Forms]![Main Form]![Year Select]) AND ((IsNull([Forms]![Main Form]!
[SBT Account Select]))<>False) AND ((IsNull([Forms]![Main Form]!
[Region Select]))<>False)) OR ((([ARCHIVE - ADM Summary].ADM)=[Forms]!
[Main Form]![ADM Select]) AND (([ARCHIVE - ADM Summary].[SBT Account])=
[Forms]![Main Form]![SBT Account Select]) AND (([ARCHIVE - ADM
Summary].Year)=[Forms]![Main Form]![Year Select]) AND ((IsNull([Forms]!
[Main Form]![Month Select]))<>False) AND ((IsNull([Forms]![Main Form]!
[Region Select]))<>False)) OR ((([ARCHIVE - ADM Summary].ADM)=[Forms]!
[Main Form]![ADM Select]) AND (([ARCHIVE - ADM Summary].[SBT Account])=
[Forms]![Main Form]![SBT Account Select]) AND (([ARCHIVE - ADM
Summary].Month)=[Forms]![Main Form]![Month Select]) AND ((IsNull
([Forms]![Main Form]![Year Select]))<>False) AND ((IsNull([Forms]!
[Main Form]![Region Select]))<>False)) OR ((([ARCHIVE - ADM
Summary].Month)=[Forms]![Main Form]![Month Select]) AND (([ARCHIVE -
ADM Summary].Year)=[Forms]![Main Form]![Year Select]) AND ((IsNull
([Forms]![Main Form]![ADM Select]))<>False) AND ((IsNull([Forms]![Main
Form]![SBT Account Select]))<>False) AND ((IsNull([Forms]![Main Form]!
[Region Select]))<>False)) OR ((([ARCHIVE - ADM Summary].[SBT Account])
=[Forms]![Main Form]![SBT Account Select]) AND (([ARCHIVE - ADM
Summary].Year)=[Forms]![Main Form]![Year Select]) AND ((IsNull([Forms]!
[Main Form]![ADM Select]))<>False) AND ((IsNull([Forms]![Main Form]!
[Month Select]))<>False) AND ((IsNull([Forms]![Main Form]![Region
Select]))<>False)) OR ((([ARCHIVE - ADM Summary].[SBT Account])=
[Forms]![Main Form]![SBT Account Select]) AND (([ARCHIVE - ADM
Summary].Month)=[Forms]![Main Form]![Month Select]) AND ((IsNull
([Forms]![Main Form]![ADM Select]))<>False) AND ((IsNull([Forms]![Main
Form]![Year Select]))<>False) AND ((IsNull([Forms]![Main Form]![Region
Select]))<>False)) OR ((([ARCHIVE - ADM Summary].ADM)=[Forms]![Main
Form]![ADM Select]) AND (([ARCHIVE - ADM Summary].Year)=[Forms]![Main
Form]![Year Select]) AND ((IsNull([Forms]![Main Form]![SBT Account
Select]))<>False) AND ((IsNull([Forms]![Main Form]![Month Select]))
<>False) AND ((IsNull([Forms]![Main Form]![Region Select]))<>False))
OR ((([ARCHIVE - ADM Summary].ADM)=[Forms]![Main Form]![ADM Select])
AND (([ARCHIVE - ADM Summary].Month)=[Forms]![Main Form]![Month
Select]) AND ((IsNull([Forms]![Main Form]![SBT Account Select]))
<>False) AND ((IsNull([Forms]![Main Form]![Year Select]))<>False) AND
((IsNull([Forms]![Main Form]![Region Select]))<>False)) OR ((([ARCHIVE
- ADM Summary].ADM)=[Forms]![Main Form]![ADM Select]) AND (([ARCHIVE -
ADM Summary].[SBT Account])=[Forms]![Main Form]![SBT Account Select])
AND ((IsNull([Forms]![Main Form]![Month Select]))<>False) AND ((IsNull
([Forms]![Main Form]![Year Select]))<>False) AND ((IsNull([Forms]!
[Main Form]![Region Select]))<>False)) OR ((([ARCHIVE - ADM
Summary].Year)=[Forms]![Main Form]![Year Select]) AND ((IsNull([Forms]!
[Main Form]![ADM Select]))<>False) AND ((IsNull([Forms]![Main Form]!
[SBT Account Select]))<>False) AND ((IsNull([Forms]![Main Form]![Month
Select]))<>False) AND ((IsNull([Forms]![Main Form]![Region Select]))
<>False)) OR ((([ARCHIVE - ADM Summary].Month)=[Forms]![Main Form]!
[Month Select]) AND ((IsNull([Forms]![Main Form]![ADM Select]))
<>False) AND ((IsNull([Forms]![Main Form]![SBT Account Select]))
<>False) AND ((IsNull([Forms]![Main Form]![Year Select]))<>False) AND
((IsNull([Forms]![Main Form]![Region Select]))<>False)) OR ((([ARCHIVE
- ADM Summary].[SBT Account])=[Forms]![Main Form]![SBT Account
Select]) AND ((IsNull([Forms]![Main Form]![ADM Select]))<>False) AND
((IsNull([Forms]![Main Form]![Month Select]))<>False) AND ((IsNull
([Forms]![Main Form]![Year Select]))<>False) AND ((IsNull([Forms]!
[Main Form]![Region Select]))<>False)) OR ((([ARCHIVE - ADM
Summary].Region)=[Forms]![Main Form]![Region Select]) AND ((IsNull
([Forms]![Main Form]![ADM Select]))<>False) AND ((IsNull([Forms]![Main
Form]![SBT Account Select]))<>False) AND ((IsNull([Forms]![Main Form]!
[Month Select]))<>False) AND ((IsNull([Forms]![Main Form]![Year
Select]))<>False)) OR ((([ARCHIVE - ADM Summary].ADM)=[Forms]![Main
Form]![ADM Select]) AND ((IsNull([Forms]![Main Form]![SBT Account
Select]))<>False) AND ((IsNull([Forms]![Main Form]![Month Select]))
<>False) AND ((IsNull([Forms]![Main Form]![Year Select]))<>False) AND
((IsNull([Forms]![Main Form]![Region Select]))<>False)) OR (((IsNull
([Forms]![Main Form]![ADM Select]))<>False) AND ((IsNull([Forms]![Main
Form]![SBT Account Select]))<>False) AND ((IsNull([Forms]![Main Form]!
[Month Select]))<>False) AND ((IsNull([Forms]![Main Form]![Year
Select]))<>False) AND ((IsNull([Forms]![Main Form]![Region Select]))
<>False));
What part did not work?
Not return all records when no selection was made?
Post the query SQL.
--
Build a little, test a little.
Erick C said:
No luck.
I even tried putting the wildcard on both ends and it still did not
work:
Like "*" & [Forms]![Main Form]![Region Select] & "*"
and I tried:
Like [Forms]![Main Form]![Region Select] & "*"
And the Region is only a one letter designation coming from the select
query, so there is not a lot of stuff that is being brought into the
combo box, just single letters.
Try this --
Like [Forms]![YourFormName]![Combo22] & "*"
If nothing is selected in the combo then it is the same as selecing all.
--
Build a little, test a little.
:
I am hoping someone can help me out with a problem that I am having..
I am setting up a database that will serve as an archive for our
reporting results. I am jsut starting to get everything together, so
I can modify anything if necessary. I made a form that has six
different combo boxes along the top. The data sources for the combo
boxes are different, some have names that I manually added. Other
boxes use select queries that I set up pulling data from certain
tables as data sources, since using the tables themselves yielded
duplicate results (the same region is listed multiple times in one
table).
In the end I want to set up buttons for various reports, and the
results will be driven by the combo box selections made on the forms.
I tried setting up a test select query, and it works for the most
part. 5 out of the 6 combo boxes will yield results if they are
selected by themselves, but one combo box will only filter the query
results when it is used in conjunction with another combo box.
It was pretty messed up setting up the query, since I had to set upa
line of criteria for each possible combination that the combo boxes
could be selected, or not selected, meaning I have 32 rows of
criteria. I can post my SQL view, but it is around 3 pages long whan
I copy it to Word
Any help I can get, or any suggestions on how I can set up my filters
so they will work better, more efficiently, I would be very grateful.
Erick- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
What part did not work?
Not return all records when no selection was made?
Post the query SQL.
--
Build a little, test a little.
Erick C said:
No luck.
I even tried putting the wildcard on both ends and it still did not
work:
Like "*" & [Forms]![Main Form]![Region Select] & "*"
and I tried:
Like [Forms]![Main Form]![Region Select] & "*"
And the Region is only a one letter designation coming from the select
query, so there is not a lot of stuff that is being brought into the
combo box, just single letters.
Try this --
Like [Forms]![YourFormName]![Combo22] & "*"
If nothing is selected in the combo then it is the same as selecing all.
--
Build a little, test a little.
:
I am hoping someone can help me out with a problem that I am having..
I am setting up a database that will serve as an archive for our
reporting results. I am jsut starting to get everything together, so
I can modify anything if necessary. I made a form that has six
different combo boxes along the top. The data sources for the combo
boxes are different, some have names that I manually added. Other
boxes use select queries that I set up pulling data from certain
tables as data sources, since using the tables themselves yielded
duplicate results (the same region is listed multiple times in one
table).
In the end I want to set up buttons for various reports, and the
results will be driven by the combo box selections made on the forms.
I tried setting up a test select query, and it works for the most
part. 5 out of the 6 combo boxes will yield results if they are
selected by themselves, but one combo box will only filter the query
results when it is used in conjunction with another combo box.
It was pretty messed up setting up the query, since I had to set upa
line of criteria for each possible combination that the combo boxes
could be selected, or not selected, meaning I have 32 rows of
criteria. I can post my SQL view, but it is around 3 pages long whan
I copy it to Word
Any help I can get, or any suggestions on how I can set up my filters
so they will work better, more efficiently, I would be very grateful.
Erick- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -