0

I don´t know whats wrong with this query... I want to know how many records are on another query named: Querie_Planilla that have the following characteristics:

  1. The date on the field PeriodoInicial has to be greater or equal to the date [FechaInicio] but a year ago
  2. The date on the field PeriodoFinal has to be smaller to the value [FechaInicio] (Both of this conditions consider the first day of the month in FechaInicio
  3. It has to have the same ID im looking for: PlazaID = [Vacaciones]![PlazaID]

Here is the code:

DCount("PlazaID","Querie_Planilla","PeriodoInicial >= #" & DateSerial(DatePart("yyyy",[FechaInicio])-1,
DatePart("m",[FechaInicio]),1) & "# AND PeriodoFinal < #" & DateSerial(DatePart("yyyy",[FechaInicio]),
DatePart("m",[FechaInicio]),1) & "# AND PlazaID = '" & [Vacaciones]![PlazaID] & "'")

Right now its returning 0 but at least i have 3 for each ID

Lio
  • 3
  • 3
  • Run the equivalent SQL query and check rows: `SELECT PlazaID FROM Querie_Planilla WHERE PeriodoInicial >= #" & DateSerial(DatePart("yyyy",[FechaInicio])-1, DatePart("m",[FechaInicio]),1) & "# AND PeriodoFinal < #" & DateSerial(DatePart("yyyy",[FechaInicio]), DatePart("m",[FechaInicio]),1) & "# AND PlazaID = '" & [Vacaciones]![PlazaID] & "'"` Update accordingly if date functions point to form fields. – Parfait Oct 26 '16 at 21:22
  • It doesn´t run with the apostrophes, but when I quit them it does run! Do I need to take them off in my original query? – Lio Oct 26 '16 at 21:52
  • Again, be sure to fix the `Forms!formname!...` to the referenced controls. Also, remove ampersands (`&`) and single/double quotes. Please post some data for reproducible example and advise where *[FechaInicio]*, *[Vacaciones]* derive. – Parfait Oct 26 '16 at 21:58

0 Answers0