completing a query

L

Lisa

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
 
L

Lisa

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
 
D

Douglas J. Steele

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)


Lisa said:
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
Jeff Boyce said:
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/
 
J

John Spencer

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
'====================================================

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
Jeff Boyce said:
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/
 
L

Lisa

John I am trying to use the changes you gave me but I get a syntax error
(missing operator) in query expression


John Spencer said:
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
'====================================================

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
Jeff Boyce said:
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
 
L

Lisa

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...
John Spencer said:
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
'====================================================

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
Jeff Boyce said:
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
 
D

Douglas J. Steele

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)


Lisa said:
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...
John Spencer said:
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
'====================================================

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
 
L

Lisa

Hello Douglas, I think it works (I had to delete 1 parentheses). Thank you
very very much for you help. And John and Jeff too.. thank you all.

Lisa
Douglas J. Steele said:
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)


Lisa said:
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...
John Spencer said:
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
 
D

Douglas J. Steele

Oops, you're correct. I did forget to remove a closing parenthesis. It
should have been

WHERE (Transazioni.Datas>=[Forms]![Reference]![DataDa] And
Transazioni.Datas<=[Forms]![Reference]![DataA]) AND
(Causali.CausaleID=[Forms]![Reference]![Causals] OR
[Forms]![Reference]![Causals] IS NULL)

Sorry about that.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Lisa said:
Hello Douglas, I think it works (I had to delete 1 parentheses). Thank you
very very much for you help. And John and Jeff too.. thank you all.

Lisa
Douglas J. Steele said:
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)


Lisa said:
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
 
L

Lisa

No problem really, I am very glad it works... thank you again

Lisa
Douglas J. Steele said:
Oops, you're correct. I did forget to remove a closing parenthesis. It
should have been

WHERE (Transazioni.Datas>=[Forms]![Reference]![DataDa] And
Transazioni.Datas<=[Forms]![Reference]![DataA]) AND
(Causali.CausaleID=[Forms]![Reference]![Causals] OR
[Forms]![Reference]![Causals] IS NULL)

Sorry about that.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Lisa said:
Hello Douglas, I think it works (I had to delete 1 parentheses). Thank
you very very much for you help. And John and Jeff too.. thank you all.

Lisa
Douglas J. Steele said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top