Buenos dias, amigos!
I created a report that gets inputs from a form using OpenArgs. When the report opens (Report_Open), it manipulates a query saved in a string (txtSQL) replacing the where condition.
<code>
Const txtSQL As String = "SELECT a.lo_cedula, a.tx_nombre, a.tx_nucleo, a.tx_sexo, c.lo_cedula_carga, c.tx_nombre_carga, " & _
"int((date()-a.fe_nacimiento)/365.24) as entEdad, c.tx_parentesco," & _
"p.tx_descripcion AS txtParentesco, n.tx_descripcion AS txtNucleo, c.tx_Sexo as txtSexoCarga, " & _
"c.fe_nacimiento, int((date()-c.fe_nacimiento)/365.24) as entEdadCarga, " & _
"c.fe_inscrito_aps, c.bo_aps, c.bo_servicio_funerario" & vbCrLf & _
"FROM ((ap_asociados AS a INNER JOIN cf_cargas_familiares AS c ON a.lo_cedula = c.lo_cedula) " & vbCrLf & _
"INNER JOIN ap_nucleos AS n ON a.tx_nucleo = n.tx_nucleo)" & vbCrLf & _
"INNER JOIN cf_parentescos AS p ON c.tx_parentesco = p.tx_parentesco" & vbCrLf & _
"WHERE a.id_estatus = '1' AND c.bo_estatus = True AND a.tx_nucleo LIKE 'DONDE_NUCLEO'"
</code>
The form pass "txtNucleo" for the where condition (DONDE_NUCLEO") and "txtOrdenar" to give an order to the report.
<code>
Private Sub Report_Open(Cancel As Integer)
...
txtMiSql = Replace(txtSQL, "DONDE_NUCLEO", txtNucleo)
Me.RecordSource = txtMiSql
End Sub
</code>
I tried with:
<code>
Private Sub Report_Load()
Me.OrderBy = txtOrdenar & ", c.tx_parentesco"
Debug.Print Me.Report.OrderBy
Me.OrderByOn = True
Me.OrderByOnLoad = True
End Sub
</code>
I put it, also, in the "Report_Open" but neither one works.
Do you have any suggestion? Is it possible to chage the order in the report, on the fly, with VBA?
I created a report that gets inputs from a form using OpenArgs. When the report opens (Report_Open), it manipulates a query saved in a string (txtSQL) replacing the where condition.
<code>
Const txtSQL As String = "SELECT a.lo_cedula, a.tx_nombre, a.tx_nucleo, a.tx_sexo, c.lo_cedula_carga, c.tx_nombre_carga, " & _
"int((date()-a.fe_nacimiento)/365.24) as entEdad, c.tx_parentesco," & _
"p.tx_descripcion AS txtParentesco, n.tx_descripcion AS txtNucleo, c.tx_Sexo as txtSexoCarga, " & _
"c.fe_nacimiento, int((date()-c.fe_nacimiento)/365.24) as entEdadCarga, " & _
"c.fe_inscrito_aps, c.bo_aps, c.bo_servicio_funerario" & vbCrLf & _
"FROM ((ap_asociados AS a INNER JOIN cf_cargas_familiares AS c ON a.lo_cedula = c.lo_cedula) " & vbCrLf & _
"INNER JOIN ap_nucleos AS n ON a.tx_nucleo = n.tx_nucleo)" & vbCrLf & _
"INNER JOIN cf_parentescos AS p ON c.tx_parentesco = p.tx_parentesco" & vbCrLf & _
"WHERE a.id_estatus = '1' AND c.bo_estatus = True AND a.tx_nucleo LIKE 'DONDE_NUCLEO'"
</code>
The form pass "txtNucleo" for the where condition (DONDE_NUCLEO") and "txtOrdenar" to give an order to the report.
<code>
Private Sub Report_Open(Cancel As Integer)
...
txtMiSql = Replace(txtSQL, "DONDE_NUCLEO", txtNucleo)
Me.RecordSource = txtMiSql
End Sub
</code>
I tried with:
<code>
Private Sub Report_Load()
Me.OrderBy = txtOrdenar & ", c.tx_parentesco"
Debug.Print Me.Report.OrderBy
Me.OrderByOn = True
Me.OrderByOnLoad = True
End Sub
</code>
I put it, also, in the "Report_Open" but neither one works.
Do you have any suggestion? Is it possible to chage the order in the report, on the fly, with VBA?