Gustav Brock
gustav at cactus.dk
Sat Oct 11 03:37:16 CDT 2014
Hi David
This is such a situation that with only ~50 steps, it is far easier to loop the recordset and run the queries where a match is found.
For each step, decide if the query shall run:
If RunQuery(Elegibility, chkElegibility, Gathered, chkGathered) = True Then
' Run the query.
End If
using a function like this:
<code>
Public Function RunQuery( _
ByVal Elegibility As Boolean, ByVal Gathered As Boolean, _
ByVal ElegibilitySelected As Boolean, ByVal GatheredSelected As Boolean) _
As Boolean
RunQuery = _
(Elegibility Imp (ElegibilitySelected And GatheredSelected)) And _
(Gathered Imp GatheredSelected)
End Function
</code>
This is, by the way, one of the rare examples for using the ignored, forgotten, and soon lost operator Imp.
/gustav
________________________________________
Fra: accessd-bounces at databaseadvisors.com <accessd-bounces at databaseadvisors.com> på vegne af David McAfee <davidmcafee at gmail.com>
Sendt: 11. oktober 2014 00:57
Til: Access Developers discussion and problem solving
Emne: [AccessD] (no subject)
So, I'm trying to figure out if my logic is correct.
I have a form with a couple of check boxes (chkEligibility & chkGathere).
I have 40+ possible steps/actionqueries that need to run.
Here is a very over simplified example:
Step Elegibility Gathered
1
2
3 X
4 X X
5 X X
6 X X
7 X
(I'm not sure if the X's lined up correctly after the email gets sent
away...)
Steps 4,5& 6 are under eligibility, 3-7 are gathered.
So the way this works is:
Steps 1 & 2 will Always run
If chkGathered is checked, 3 & 7 will also run, but 4-6 will only run if
chkGathered and chkEligibility are both checked
If chkEligibility is checked, but Gathered isn't, only steps 1 & 2 will run.
I originally was using a procedure to change the queryDef based on two
different check box combinations, and I decided to just make one query
dynamic instead.
The following query DOES work correctly, but it just seems messy / ugly.
Is there a way to simplify it? Am I overlooking something obvious?
SELECT PKID, Step, Task, Action, Started, Completed, EligibilitySection,
GatheredSection
FROM tblMiniCostReportBuildSteps
WHERE
(Completed=0 AND EligibilitySection=False AND
(GatheredSection=IIf([forms]![frmBuildMiniCostReport]![chkGatherMode]=False,False,[forms]![frmBuildMiniCostReport]![chkGatherMode]
In (True,False))))
OR
(Completed=0 AND EligibilitySection=False AND GatheredSection=False)
OR
(Completed=0 AND
(EligibilitySection=IIf([forms]![frmBuildMiniCostReport]![chkEligibilityMode]=False,False,[forms]![frmBuildMiniCostReport]![chkEligibilityMode]
In (True,False)))
AND
(GatheredSection=IIf([forms]![frmBuildMiniCostReport]![chkGatherMode]=False,False,[forms]![frmBuildMiniCostReport]![chkGatherMode]
In (True,False))));
Thanks in advance...
David