Hey there!
I'm working on a form so the user can perform an SQL query without realizing he's actually doing it. So, I have a form with 2 date fields and 4 comboboxes, linked in pairs so the second will display a list depending on what the user selected on the first.
The thing is, if the user does not choose an option in one of the comboboxes, the query does not work. This is the query I was originally using (showing here only the "where" bit):
Here, dbo_temp_aof_reativos_ferramenta is my SQL DB connected to Access;
Indicadores is my form;
Area2, coordenacao2, jornada2 and subjornada2 are the comboboxes.
Searching online, I found a similar query using IFF for when the user does not want to select a value in one or more comboboxes, shown below:
But this also does not work. Is there anything else I could do?
Thanks in advance!! =D
I'm working on a form so the user can perform an SQL query without realizing he's actually doing it. So, I have a form with 2 date fields and 4 comboboxes, linked in pairs so the second will display a list depending on what the user selected on the first.
The thing is, if the user does not choose an option in one of the comboboxes, the query does not work. This is the query I was originally using (showing here only the "where" bit):
Code:
WHERE (((dbo_temp_aof_reativos_ferramenta.area)=[Forms]![Indicadores]![Area2]) AND ((dbo_temp_aof_reativos_ferramenta.coordenacao)=[Forms]![Indicadores]![coordenacao2]) AND ((dbo_temp_aof_reativos_ferramenta.data_abertura) Between [Forms]![Indicadores]![DATAIN] And [Forms]![Indicadores]![DATAFIM]) AND ((dbo_temp_aof_reativos_ferramenta.jornada)=[Forms]![Indicadores]![jornada2]) AND ((dbo_temp_aof_reativos_ferramenta.subjornada)=[Forms]![Indicadores]![subjornada2]));
Indicadores is my form;
Area2, coordenacao2, jornada2 and subjornada2 are the comboboxes.
Searching online, I found a similar query using IFF for when the user does not want to select a value in one or more comboboxes, shown below:
Code:
WHERE (dbo_temp_aof_reativos_ferramenta.data_abertura Between Forms!Indicadores!DATAIN And Forms!Indicadores!DATAFIM) And IIf(Not IsNull(Forms!Indicadores!Area2),dbo_temp_aof_reativos_ferramenta.area=Forms!Indicadores!Area2) And IIf(Not IsNull(Forms!Indicadores!coordenacao2),dbo_temp_aof_reativos_ferramenta.coordenacao=Forms!Indicadores!coordenacao2) And IIf(Not IsNull(Forms!Indicadores!jornada2),dbo_temp_aof_reativos_ferramenta.jornada=Forms!Indicadores!jornada2) And IIf(Not IsNull(Forms!Indicadores!subjornada2),dbo_temp_aof_reativos_ferramenta.subjornada=Forms!Indicadores!subjornada2);
Thanks in advance!! =D
Last edited: