Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I've write this query in an access 2007 database:

SQL
SELECT Ordini.ID, Ordini.Data, Clienti.Cognome, Clienti.Nome, DettagliOrdine.IDProdotto, Prodotti.Descrizione, Prodotti.Prezzo, DettagliOrdine.Quantità, ([Prezzo]*[Quantità]) AS Totale, Ordini.Note, Produttori.Nome, Ordini.Ordinato, Ordini.Arrivato, Ordini.Ritirato
FROM Produttori INNER JOIN (Prodotti INNER JOIN ((Clienti INNER JOIN Ordini ON Clienti.ID = Ordini.IDCliente) INNER JOIN DettagliOrdine ON Ordini.ID = DettagliOrdine.IDOrdine) ON Prodotti.ID = DettagliOrdine.IDProdotto) ON Produttori.ID = Prodotti.IDFornitore
WHERE (((Clienti.Cognome)=[Cognome: ]) AND ((Clienti.Nome)=[Nome: ]) AND (([Cognome: ]) Is Not Null))ORDER BY Ordini.Data;


This query brings up an input box for the COGNOME and NOME field of research.

I need that if user write nothing (press ENTER) for that field research tag is . (all value of that field).

es. If user write a COGNOME but not a NOME (press ENTER when popup NOME window) research to be done on all the NOME with that "COGNOME".

How can I do this?
Posted

1 solution

There are 2 options:
1) building queries "On the Fly" using userform and VBA[^] or
2) using IIF function[^] with declaration of PARAMETERS[^]

SQL
PARAMETERS param1 CHAR, param2 CHAR;
SELECT ...
FROM ...
WHERE Field1 = IIF([param1] IS NULL,'*',[param1]) AND Field2 = IIF([param2] IS NULL, '*', [param2]) 


Not tested, but should works fine.
 
Share this answer
 
Comments
Domus1919 22-Nov-13 3:59am    
don't work...don't select inserted field in popup window, or select all always...please help me...
Maciej Los 22-Nov-13 4:19am    
So... Use the first option ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900