If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
WHERE help needed
I have SQL that works fine, but I have a question about the WHERE conditions
SELECT ...... FROM ........ WHERE (((K.HardwareClass)=[Forms]![frmHardware].[cbxHClass]) AND ((K.HardwareType)=[Forms]![frmHardware].[cbxHType])); If both cbxHClass and cbxHType have values, then the query works as planned. However, I would like it to work even if one of the cbx's is empty, in which case only one WHERE clause would apply and I have to 'lose' the AND. If both cbxs are empty, there would be no WHERE at all. Can this be done? (For what its worth, cbxHClass has numerical values, while cbxHType has literal values. -- Thanks Sophie |
#2
|
|||
|
|||
WHERE help needed
Sophie wrote:
I have SQL that works fine, but I have a question about the WHERE conditions SELECT ...... FROM ........ WHERE (((K.HardwareClass)=[Forms]![frmHardware].[cbxHClass]) AND ((K.HardwareType)=[Forms]![frmHardware].[cbxHType])); If both cbxHClass and cbxHType have values, then the query works as planned. However, I would like it to work even if one of the cbx's is empty, in which case only one WHERE clause would apply and I have to 'lose' the AND. If both cbxs are empty, there would be no WHERE at all. Can this be done? (For what its worth, cbxHClass has numerical values, while cbxHType has literal values. SELECT ...... FROM ........ WHERE (K.HardwareClass = [Forms]![frmHardware].[cbxHClass] OR [Forms]![frmHardware].[cbxHClass] Is Null) AND (K.HardwareType = [Forms]![frmHardware].[cbxHType] OR [Forms]![frmHardware].[cbxHType] Is Null); -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
Thread Tools | |
Display Modes | |
|
|