Define search

Spikemannen

Registered User.
Local time
Today, 08:22
Joined
Apr 18, 2005
Messages
15
Hi!

I have a table with x columns.
In a form I can choose 4 different columns to define my search.
Now, I have this SQL-statement, that strangely doesn't work. Can someone help me with this?

Code:
SELECT a.Nr, a.Objekt, a.Applikation, a.Modul, a.Datum, a.Anmalare, a.Onskemal, a.Klart, a.Prio, a.Status, a.Ansvarig
FROM tblArenden AS a
WHERE ((IIf(Not IsNull(Forms!frmFiltrera!cboObjekt),a.Objekt Like Forms!frmFiltrera!cboObjekt & "*","*"))<>False) And ((IIf(Not IsNull(Forms!frmFiltrera!cboApplikation),a.Applikation Like Forms!frmFiltrera!cboApplikation & "*","*"))<>False) And ((IIf(Not IsNull(Forms!frmFiltrera!Prio),a.Prio Like Forms!frmFiltrera!Prio & "*","*"))<>False);
 
Try this query:-

SELECT Nr, Objekt, Applikation, Modul, Datum, Anmalare, Onskemal, Klart, Prio, Status, Ansvarig
FROM tblArenden
WHERE
(IIf(Not IsNull(Forms!frmFiltrera!cboObjekt), Objekt = Forms!frmFiltrera!cboObjekt, True)<>False) And
(IIf(Not IsNull(Forms!frmFiltrera!cboApplikation), Applikation = Forms!frmFiltrera!cboApplikation, True)<>False) And
(IIf(Not IsNull(Forms!frmFiltrera!Prio), Prio Like "*" & Forms!frmFiltrera!Prio & "*", True)<>False);


For the combo boxes cboObjekt and cboApplikation, you can use the = sign for exact matches, rather than the Like operator which is normally used for partial matches.

The Prio Like "*" & Forms!frmFiltrera!Prio & "*" will match characters anywhere inside the Prio field. If what you want is only to match characters beginning from the left in the field, you can change it to:-

Prio Like Forms!frmFiltrera!Prio & "*"

^
 

Users who are viewing this thread

Back
Top Bottom