You sure you got the parentheses the same as I had them?
Here's a slightly simplified form, removing some of the unnecessary
parentheses Access inserted:
WHERE (Transazioni.Datas>=[Forms]![Reference]![DataDa] And
Transazioni.Datas)<=[Forms]![Reference]![DataA]) AND
(Causali.CausaleID=[Forms]![Reference]![Causals] OR
[Forms]![Reference]![Causals] IS NULL)
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
I have also tried Douglas solution but that gives me all the
transactions in my database and not only the ones between the chosen
dates...
If Causali.CausaleID is a text field then you can use
PARAMETERS [Forms]![Reference]![DataDa] DateTime,
[Forms]![Reference]![DataA] DateTime;
SELECT Transazioni.Importo, Transazioni.Note, Anagrafica.Nome,
Anagrafica.Cognome, Causali.Causale, Transazioni.Datas,
Anagrafica.Indirizzo, Anagrafica.[Cap&Citta], Anagrafica.Provincia,
Anagrafica.SysDate, Anagrafica.Email
FROM Causali RIGHT JOIN (Anagrafica RIGHT JOIN Transazioni ON
Anagrafica.AnagraficaID = Transazioni.AnagraficaID) ON
Causali.CausaleID =
Transazioni.CausaleID
WHERE (((Transazioni.Datas)>=[Forms]![Reference]![DataDa] And
(Transazioni.Datas)<=[Forms]![Reference]![DataA]) AND
((Causali.CausaleID) LIKE Nz([Forms]![Reference]![Causals],"*"))
ORDER BY Transazioni.Datas;
If the field is numeric, then you can try the following
WHERE
(Transazioni.Datas >=[Forms]![Reference]![DataDa] And
Transazioni.Datas<=[Forms]![Reference]![DataA])
AND
(Causali.CausaleID=[Forms]![Reference]![Causals] OR
[Forms]![Reference]![Causals]Is Null)
WARNING: Access will rearrange this query criteria into a more complex
format when you save the query and reopen it. It will add a
calculated column with [Forms]![Reference]![Causals] as the value and
then will create two lines of criteria. One where it checks the value
of [Forms]![Reference]![Causals] is null along with the dates and a
second where it check all three fields, but ignores the new column.
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
Lisa wrote:
Hi Jeff, the query works fine.. I only need to have a way to show all
the "causali" if I don't select anything in the combobox. Here you
have my query sql...
PARAMETERS [Forms]![Reference]![DataDa] DateTime,
[Forms]![Reference]![DataA] DateTime;
SELECT Transazioni.Importo, Transazioni.Note, Anagrafica.Nome,
Anagrafica.Cognome, Causali.Causale, Transazioni.Datas,
Anagrafica.Indirizzo, Anagrafica.[Cap&Citta], Anagrafica.Provincia,
Anagrafica.SysDate, Anagrafica.Email
FROM Causali RIGHT JOIN (Anagrafica RIGHT JOIN Transazioni ON
Anagrafica.AnagraficaID = Transazioni.AnagraficaID) ON
Causali.CausaleID = Transazioni.CausaleID
WHERE (((Transazioni.Datas)>=[Forms]![Reference]![DataDa] And
(Transazioni.Datas)<=[Forms]![Reference]![DataA]) AND
((Causali.CausaleID)=[Forms]![Reference]![Causals]))
ORDER BY Transazioni.Datas;
Thanks
Lisa
message Lisa
If your query needs to display the "causali", you'll first need to
make sure
it is set to do that, not just use it as a selection
criteria/parameter.
Or are you trying to do two separate queries?
--
Regards
Jeff Boyce
www.InformationFutures.net
Microsoft Office/Access MVP
Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
Hello everybody. I have this query which works fine. It takes its
parameters
(date from - date to - reasons) from a form. This works also fine.
I
sometimes need to be able to see all the reasons "causali" between
specific
dates. I would like to know if and how that is possible by just
leaving
the
"causali" combobox empty. Of course any other suggestion is more
than
welcome
Thanks
--
Lisa
Save the Dogs Onlus -
www.savethedogs.eu
Aiutaci a costruire il nuovo rifugio, dona il 5 per mille a Save
The Dogs
:
97394230151