Boletín mugperu Digital - Julio 2009!
  Search 
Saturday, May 19, 2012 ..:: Foros de Discusión ::.. Register  Login
Foros MUGPERU Minimize
Subject: Problemas con el crystal report 9 y VB6
Prev Next
You are not authorized to post a reply.

Author Messages
oblacionx
Posts:3

04/05/2005 02:21 PM  
en una pregunta anterior algunos me repondieron, como podia hacer reportes y conectarlos al visual basic, alguien me dijo usa un RDC, le consulte q era pero parece q se paso las pregunta de tiempo, ok les narro mi problema tengo reportes en Crystal report 9, de alli me nacen 2 problemas, mis reportes son diseñados no por tablas o vistas , sino por procedures porq necesito q el usuario tenga la opcion de escoger q reguistros se les mostrara, es decir si tengo los productosa de 5 tiendas, el puede escoger solo lso de una tienda , la estructura de mi procedure es :

CREATE PROCEDURE p_rpt_ventasdiadetalletienda
( @Int INTEGER,
@Tienda VARCHAR(30)
)
AS
-- Int=1 Muestra todos las tiendas
-- Int=2 Muestra las tiendas coincidentes

IF @Int = 1
BEGIN
SELECT NomTie as 'Tienda',Vendedor as 'Vendedor',PrePro as 'Prefijo',
DesPro as 'Descripcion',CanTot as 'Cantidad Total',
VenTot as 'Ventas Totales',CanProSto as 'Stock',NomFab as 'Fabricante'
FROM v_rep_ventasdia_res_tienda
ORDER BY NomTie,Vendedor
END

IF @Int= 2
BEGIN
SELECT NomTie as 'Tienda',Vendedor as 'Vendedor',PrePro as 'Prefijo',
DesPro as 'Descripcion',CanTot as 'Cantidad Total',
VenTot as 'Ventas Totales',CanProSto as 'Stock',NomFab as 'Fabricante'
FROM v_rep_ventasdia_res_tienda
WHERE UPPER(NomTie) LIKE UPPER(@Tienda + '%')
ORDER BY NomTie,Vendedor
END

he usado un formulario de donde el ususario puede ingresar en un textbox si desea el nombre de una tienda, y alli hay un boton:
If txtBuscar.Text = "" Then
txtParametro1 = 1
txtParametro2 = ""
Else
txtParametro1 = 2
txtParametro2 = txtBuscar.Text
End If

Dim frmRep As New frmImpVentasMesDetalleTienda
frmRep.PasarParametros CInt(txtParametro1), CStr(txtParametro2)
frmRep.Show
Set frmRep = Nothing
y en otro form que contiene el viewer el codigo es:

Private crApp As New CRAXDRT.Application
Private crReport As New CRAXDRT.Report
Private mflgContinuar As Boolean
Private mintParametro1 As Integer
Private mstrParametro2 As String

Private Sub Form_Activate()
If Not mflgContinuar Then Unload Me
End Sub

Private Sub Form_Resize()
CRViewer.Top = 0
CRViewer.Left = 0
CRViewer.Height = ScaleHeight
CRViewer.Width = ScaleWidth
End Sub

Public Sub PasarParametros(iParam1 As Integer, sParam2 As String)
mintParametro1 = sParam1
mstrParametro2 = lParam2
End Sub

Private Sub Form_Load()
Dim crParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim crParamDef As CRAXDRT.ParameterFieldDefinition

On Error GoTo ErrHandler
'Abrir el reporte
Screen.MousePointer = vbHourglass
mflgContinuar = True
Set crReport = crApp.OpenReport(App.Path & "\dtrptVentasDiaDetalleTienda.rpt", 1)

' Parametros del reporte
Set crParamDefs = crReport.ParameterFields
For Each crParamDef In crParamDefs
Select Case crParamDef.ParameterFieldName
Case "@Int"
crParamDef.AddCurrentValue (mintParametro1)
Case "@Tienda"
crParamDef.AddCurrentValue (mstrParametro2)
End Select
Next

CRViewer.ReportSource = crReport
CRViewer.DisplayGroupTree = False
CRViewer.ViewReport
Scren.MousePointer = vbDefault

Set crParamDefs = Nothing
Set crParamDef = Nothing
Exit Sub

ErrHandler:
If Err.Number = -2147206461 Then
MsgBox "El archivo de reporte no se encuentra, restáurelo de los discos de instalación", _
vbCritical + vbOKOnly, "Mensaje"
Else
MsgBox Err.Description, vbCritical + vbOKOnly, "Mensaje"
End If

mflgContinuar = False
Screen.MousePointer = vbDefault
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set crReport = Nothing
Set crApp = Nothing
End Sub

pero ne sale error de que hay campos q no se encuentran, creo yo que puede ser q ha sido diseñado en otra pc y en otro servidor, para esto deseaba usar un ODBC que se llame sistema.dns pero no se como hacer para q la conexion no dependa de la pcp donde se diseño el reporte y sin hacerlo q solo sea (local), les agradecere su ayuda. La verdad ya no se que hacer hasta ahora no veo un solo reporte.
zCreed
Posts:0

12/05/2005 09:41 AM  

Saludos..

Te queria consultar antes que nada, si hasprobado tu reporte directamente en el crystal reports dandole valores a los parametros del store procedure q llamas, debido a que si lo pruebas y salen los errores q aparecen al mostrarlo el problema es el reporte o tu store.

Te muestro como muestro yo los reportes, en este caso uso CR 10 y oracle pero uso RDC igualmente y procediminentos

Dim CRAp As New CRAXDRT.Application
Dim CRRep As New CRAXDRT.Report

En el Load del Formulario

Set CRRep = CRAp.OpenReport(App.Path & "\Reportes\repRelojxPers.rpt")
CRRep.Database.LogOnServer DllOracle, Nombre_Servicio, "", Usuario_BD, Contraseña_BD

'Le paso los parametros de conexion y la dll respectiva
Los parametros para el LogOnServer son
DllName : Nombre de la Dll a usar por la conexion del reporte, si usas ODBC tienes q usar esta dll  "PDSODBC.DLL" y si usas SQL Server esta dll "P2SSQL.DLL"
pServerName : Nombre del servidor
pDatabaseName : Nombre de tu BD
pUserID : UsuarioBD
pPassword : Password BD

y de ahi lo muestro

Private Sub cmdVerReporte_Click()
On Error GoTo errHandler
Dim strCodTra As String
Dim strReloj As String

If ctlbPersonal.Codigo <> "" And ctlbPersonal.Descripcion <> "" Then
    strCodTra = ctlbPersonal.Codigo
End If

If ctlBReloj.Codigo <> "" And ctlBReloj.Descripcion <> "" = True Then
    strReloj = ctlBReloj.Codigo
End If

CRRep.FormulaFields.Item(1).Text = " '" & DarFormato(mfecgen, FormatoFecha) & "' "

CRRep.ParameterFields.Item(1).ClearCurrentValueAndRange
CRRep.ParameterFields.Item(2).ClearCurrentValueAndRange
CRRep.ParameterFields.Item(3).ClearCurrentValueAndRange

CRRep.ParameterFields.Item(1).AddCurrentValue CStr(mintAnioActual)
CRRep.ParameterFields.Item(2).AddCurrentValue strReloj
CRRep.ParameterFields.Item(3).AddCurrentValue strCodTra

CRVReporte.ReportSource = CRRep
CRVReporte.ViewReport
Exit Sub

errHandler:
    errManager Err.Number, Err.Description, Err.Source
End Sub
Como veras paso los parametros por la referencia del indice y no creo variables de tipo parametro para añadirlas al reporte y con esto no tengo ningun problema.

Ojala te haya ayudado en algo..
hablamos

You are not authorized to post a reply.



ActiveForums 3.7
        
Copyright 2001-2012 MUGPERU   Terms Of Use  Privacy Statement