strange problem with crystal report 8.0

giannicotina
04-20-2004, 06:24 PM
Hi,

i'm having a strange problem when using CR8.0 with my vb6 application.

I'm using this code in vb to dinamically change a template report that i made:


Public Sub dynamicCrystal6(dbName As String)

sSQL2 = "Select * From usuarios_grupos where GRUPOTEXTO='" & grupo & "' "
Set RS2 = m_cn.Execute(sSQL2)
grupo = RS2("grupotexto")
periodoant = RS2("periodoactual") - 1
periodoact = RS2("periodoactual")

If periodoant = 0 Then

'MsgBox "El grupo de trabajo se encuentra en el periodo 1.No existen informes de niveles de riesgo de periodos anteriores."
NoInformes.Show
PicOutput.Visible = False
Else

SWFImprimir.Visible = True
PicOutput.Visible = True


Set RS = New ADODB.Recordset
sSQL = "Select * From Historico3_" & grupo & " where USUARIO='" & usuario_report & "'"
Set RS = m_cn.Execute(sSQL)


Set crxRpt = crxApp.OpenReport(App.Path & "\report\Report6v2.rpt", 1)

For Each crxTable In crxRpt.Database.Tables
crxTable.Location = dbName
Next

crxRpt.DiscardSavedData

crxRpt.Database.SetDataSource RS

Set crParamDefs = crxRpt.ParameterFields

crxRpt.EnableParameterPrompting = False

For Each crParamDef In crParamDefs
With crParamDef
Select Case .ParameterFieldName

Case "periodoact"
.ClearCurrentValueAndRange
.SetCurrentValue periodoact
Case "usuarioactual"
.ClearCurrentValueAndRange
.SetCurrentValue usuario_report
Case "grupoactual"
.ClearCurrentValueAndRange
.SetCurrentValue grupo
End Select
End With
Next

If imprimir = False Then
CRViewer1.ReportSource = crxRpt
CRViewer1.ViewReport
CRViewer1.Zoom (85)
ElseIf imprimir = True Then
crxRpt.PrintOut
End If
imprimir = False
End If
End Sub



In the report i have 14 fields coming from a database table that has exactly the same structure as

Historico3_" & grupo & "

(so i just change the origin of data)

My problem is that i just get 13 results shown in the final report (with the first one not showing and the others showing in wrong place, actually, in the place before where they should be)

What's wrong??

Thanks!

PS: all database fields have data in them

MKoslof
04-20-2004, 07:22 PM
Well, not sure what you mean. So, in your initial report the data comes in correctly. But, if you change data sources the data is placed in the wrong spot? Are the fields in the same location?

giannicotina
04-21-2004, 02:49 AM
thanks for replying mkoslof,

the fields are allways in the same location and they are in the right place, only that when i assign the new recordset (RS) to the report i get the values in the wrong places (one place up where they should be, and with the first one not showing)

any idea?

giannicotina
04-21-2004, 08:29 AM
hi,

i've solved my problem.

The error was that the original table from database (the one i used to create the template report) had an autonumeric field that the other table didn't.

Thank you so much for your help!

MKoslof
04-21-2004, 09:25 AM
OK, glad you got it to work :). I am quite busy today at work, so I am not going to be as assessible as usual. Good luck.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum