I am in need of some advice please. I am using MSAccess 2003 SP2 for this example. I am trying to create a report using the following query in VBA:
Option Compare Database: Dim Completed As Integer: Dim FA As Date
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Completed = 1 Then Exit Sub
Completed = 1
Nombre = "Rene Torres"
Dim rs As DAO.Recordset: Dim db As Database: Set db = CurrentDb()
strsql = "SELECT Tecnico, Problema, Mantenimiento, Proyecto, Sum(horas + minutos) AS Tiempo, [Fecha actual], OT FROM TB_Eventos GROUP BY Tecnico, Problema, Mantenimiento, Proyecto, [Fecha actual], OT, Horas, Minutos HAVING Tecnico = '" & Nombre & "'"
Set rs = db.OpenRecordset(strsql)
[Reports]![rep_Reporte_Tecnico]![Tecnico] = rs!Tecnico
rs.MoveFirst: Do Until rs.EOF
[Reports]![rep_Reporte_Tecnico]![FechaActual] = rs![Fecha actual]
[Reports]![rep_Reporte_Tecnico]![Tiempo] = rs![Tiempo]
[Reports]![rep_Reporte_Tecnico]![Problema] = rs![Problema]
[Reports]![rep_Reporte_Tecnico]![Mantenimiento] = rs![Mantenimiento]
[Reports]![rep_Reporte_Tecnico]![Proyecto] = rs![Proyecto]
[Reports]![rep_Reporte_Tecnico]![OT] = rs![OT]
rs.MoveNext: Loop: rs.Close: Set rs = Nothing: DoCmd.Echo True
End Sub
The report and query appears to be working just fine, it is looping through the records and returning 11 records. The problem is that there is only 1 record showing up on the report which so happens to be the last record returned. Any ideas what I might be doing wrong, I have been working on this for days and am getting nowhere. Thanks a bunch for any suggestions.
Option Compare Database: Dim Completed As Integer: Dim FA As Date
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Completed = 1 Then Exit Sub
Completed = 1
Nombre = "Rene Torres"
Dim rs As DAO.Recordset: Dim db As Database: Set db = CurrentDb()
strsql = "SELECT Tecnico, Problema, Mantenimiento, Proyecto, Sum(horas + minutos) AS Tiempo, [Fecha actual], OT FROM TB_Eventos GROUP BY Tecnico, Problema, Mantenimiento, Proyecto, [Fecha actual], OT, Horas, Minutos HAVING Tecnico = '" & Nombre & "'"
Set rs = db.OpenRecordset(strsql)
[Reports]![rep_Reporte_Tecnico]![Tecnico] = rs!Tecnico
rs.MoveFirst: Do Until rs.EOF
[Reports]![rep_Reporte_Tecnico]![FechaActual] = rs![Fecha actual]
[Reports]![rep_Reporte_Tecnico]![Tiempo] = rs![Tiempo]
[Reports]![rep_Reporte_Tecnico]![Problema] = rs![Problema]
[Reports]![rep_Reporte_Tecnico]![Mantenimiento] = rs![Mantenimiento]
[Reports]![rep_Reporte_Tecnico]![Proyecto] = rs![Proyecto]
[Reports]![rep_Reporte_Tecnico]![OT] = rs![OT]
rs.MoveNext: Loop: rs.Close: Set rs = Nothing: DoCmd.Echo True
End Sub
The report and query appears to be working just fine, it is looping through the records and returning 11 records. The problem is that there is only 1 record showing up on the report which so happens to be the last record returned. Any ideas what I might be doing wrong, I have been working on this for days and am getting nowhere. Thanks a bunch for any suggestions.