View Full Version : SQL edit for addition of combo box


willr
10-15-2009, 08:50 AM
Hi there,

If someone could help with this it would be greatly appreciated. I'm using a form (Main_Report_1) with two combo boxes each linked to their respective tables (tbl_System_Id.System_id and tbl_Protection_Type.Protection_Type) the selection of the data or null in either combo box will filter the data out in tbl_EX_register to what I want.

The SQL code is:
FROM tbl_System_Id INNER JOIN (tbl_Protection_Type INNER JOIN tbl_EX_register ON tbl_Protection_Type.Protection_Type=tbl_EX_registe r.[Protection Concept ex-]) ON tbl_System_Id.System_id=tbl_EX_register.[System No]
WHERE (((tbl_System_Id.System_id)=Forms!Main_Report_1!cb oSystem_Id) And ((tbl_Protection_Type.Protection_Type)=Forms!Main_ Report_1!cboProtection_Type)) Or (((tbl_Protection_Type.Protection_Type)=Forms!Main _Report_1!cboProtection_Type) And ((IsNull(Forms!Main_Report_1!cboSystem_Id))<>False)) Or (((tbl_System_Id.System_id)=Forms!Main_Report_1!cb oSystem_Id) And ((IsNull(Forms!Main_Report_1!cboProtection_Type))<>False)) Or (((IsNull(Forms!Main_Report_1!cboSystem_Id))<>False) And ((IsNull(Forms!Main_Report_1!cboProtection_Type))<>False));

This works perfectly. I now want to add another combo box (cboStatus.Status) linked to a third table (tbl_Status) which will work with the two combo's I already have to filter out where the filtered dat occurs.

Thanks in advance.

namliam
10-15-2009, 11:56 PM
The more combo's you add the more complex things get... I advice you to abandon this way of doing things and making an actual "search form"

By doing so you will skip the blank / null combo's all together instead of making exceptions all over the place...

Have a search on the forum for "search form" and see if you can get anywhere... if not come back here and ask specific questions.

Good luck!

PS, dont just splash SQL on the forum, please use some kind of formatting as well as the code tags...

FROM tbl_System_Id
INNER JOIN (tbl_Protection_Type
INNER JOIN tbl_EX_register ON tbl_Protection_Type.Protection_Type=tbl_EX_registe r.[Protection Concept ex-])
ON tbl_System_Id.System_id=tbl_EX_register.[System No]
...etc


This will make the chances of you getting a "better" reply much greater as unreadable/uninviting/unattentive posts tend to get less attention than someone spending a few minutes to "take care of business"