I have a query named EstadosHistoricos_AUX_Nuevo with the following fields:
ID_LEAD - Numeric
FECHA DE ALTA - Date
FECHA HCO LEAD - Date
ID_HCO_LEAD - Numeric
ID_TIPO_ACCION - Numeric
I am trying to run a second query on this one that gives me the following:
For those records with a FECHA HCO LEAD less than a certain date from a form ([Forms]![frmNavegacion]![SubformularioDeNavegación].[Form]![txtFechaInformes].[Value]) I want to obtain the maximum of ID_HCO_LEAD.
For the rest of the cases (FECHA HCO LEAD is null or FECHA HCO LEAD is greater than the date from the Form, I want to obtain a text string.
I have created this query:
Code: Select all
SELECT EstadosHistoricos_AUX_Nuevo.ID_LEAD, IIf([EstadosHistoricos_AUX_Nuevo].[FECHA_HCO_LEAD]<[Forms]![frmNavegacion]![SubformularioDeNavegación].[Form]![txtFechaInformes].[Value],Max([EstadosHistoricos_AUX_Nuevo].[ID_HCO_LEAD]),"Se debe poner a 1") AS MáxDeID_HCO_LEAD, EstadosHistoricos_AUX_Nuevo.FECHA_HCO_LEAD
FROM EstadosHistoricos_AUX_Nuevo
GROUP BY EstadosHistoricos_AUX_Nuevo.ID_LEAD, EstadosHistoricos_AUX_Nuevo.FECHA_HCO_LEAD;
What is wrong in my query?
Thanks