Take a look at my signature.
Cannot explain things properly, but will try to do it hoping for corrections & inputs from the experts :
1) The 1 = 1 .
Why is it there ?
Suppose, I have a form with 5 search text fields & the user doesn't enter anything in those fields & submits the Form, then I would like it to return all the records. In this case All the IF's will not feed the query anything, hence the "WHERE 1 = 1".
To understand it better, take a look at the VBA pseudo-code written earlier.
In the query code example, which I had given earlier, try removing the "1 = 1" & I think, it should still work in your case.
2)
Code:
(
IIf(
[Forms]!frmJournalMain!chkKritisk=True, [Forfaldsdato] Like "*", Date()>[Forfaldsdato]
)
)<>False
This is a bit difficult for me to explain.
The above criteria evaluates each record for the condition to either a True or a False (-1 or 0) & then we filter it on "<>False".
To understand it better, Go in to the Query Builder View for your query & give an alias name to the IIf(), something like below.
Code:
SELECT
field1,
field2,
Forfaldsdato,
IIf([Forms]!frmJournalMain!chkKritisk=True, [Forfaldsdato] Like "*", Date()>[Forfaldsdato]) AS ActiveDate
FROM
myTable;
Take a look at the results.
Then add below clause to the query at the end :
Code:
WHERE (((IIf([Forms]!frmJournalMain!chkKritisk=True, [Forfaldsdato] Like "*", Date()>[Forfaldsdato]))<>False));
Take a look at the results.
Then add, instead of above WHERE clause, below clause to the query at the end :
Code:
WHERE (((IIf([Forms]!frmJournalMain!chkKritisk=True, [Forfaldsdato] Like "*", Date()>[Forfaldsdato]))<>True));
Take a look at the results.
Hope someone explains this better.
PS : I still do not know whether the solution that I have suggested to you is an efficient way of doing it, but currently, that is the only way I know.
Thanks