RE:CRYSTAL SQLQUERY con ACCESS
Aquí va el ejemplo (Funciona sin problemas), primero debes crear el Query sin eliminarlo para poder poder generar el reporte (solo rvidrios.rpt está con query). Saludos ...
Dim ReporteSeleccionado As String
Dim Fecha1 As String
Dim Fecha2 As String
Dim miquery As QueryDef
On Error GoTo ErrorImpresion
If Not IsDate(TxtFechaDe.Text) Then
MsgBox "Fecha de inicio no válida"
SendKeys "{home}+{end}"
TxtFechaDe.SetFocus
Exit Sub
End If
If Not IsDate(TxtFechaA.Text) Then
MsgBox "Fecha de término no válida"
SendKeys "{home}+{end}"
TxtFechaA.SetFocus
Exit Sub
End If
FrmVentas.CR1.DataFiles(0) = Trim(DirectorioBD) + Trim(NombreBD)
If Index = 0 Then
ReporteSeleccionado = "rcredito.rpt"
Fecha1 = Format(TxtFechaDe.Text, "YYYY") + "," + Format(TxtFechaDe.Text, "mm") + "," + Format(TxtFechaDe.Text, "dd")
Fecha2 = Format(TxtFechaA.Text, "YYYY") + "," + Format(TxtFechaA.Text, "mm") + "," + Format(TxtFechaA.Text, "dd")
FrmVentas.CR1.ReportFileName = Trim(DirectorioReportes) & ReporteSeleccionado
FrmVentas.CR1.SelectionFormula = "{CuentaClientes.CC_fecha}>=Date(" + Fecha1 + ") and {CuentaClientes.CC_Fecha}<=Date(" + Fecha2 + ")"
Else
ReporteSeleccionado = "rvidrios.rpt"
FrmVentas.CR1.ReportFileName = Trim(DirectorioReportes) & ReporteSeleccionado
Consulta = "select left(V_Codigo,5) as SFamilia,* f