Hi!
I am really new in programming with VB. I would like to run a Crystal reports from a VB form after the user has selected the report he wants to run. I do not know why, but I cannot find which command I have to run. I tried the SHELL command but it looks like it is only working with an .EXE file.
Anyone could help me?
Here is the code I made.
Public strMessage As String
Private Sub File1_Click()
drivelist.Drive = "c:"
End Sub
Private Sub cmdCancel_Click()
MsgBox "CANCELLED"
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim strMessage
strMessage = "Drive: " & drvDialog.Drive
strMessage = strMessage & vbCr & "Path: " & dirDialog.Path
strMessage = strMessage & vbCr & "Filename: " & filDialog.FileName
strMessage = strMessage & vbCr & "The lot: "
If Right(filDialog.Path, 1) = "\" Then
strMessage = filDialog.Path & filDialog.FileName
Else
strMessage = filDialog.Path & "\" & filDialog.FileName
End If
MsgBox strMessage
'ret = Shell(strMessage, 1)
'Instead of running this report.exe, I would like to run a .RPT file
Unload Me
End Sub
Private Sub Form_Load1()
Dim crApplication As New CRAXDRT.Application
Dim Report As CRAXDRT.Report
Set Report = crApplication.OpenReport("C:\activity.rpt"
'Set Report = crApplication.OpenReport("strMessage"
With Report.Database.Tables(1).ConnectionProperties
.Item("DSN" = "I"
.Item("Database" = "I"
.Item("User ID" = "laurence"
.Item("Password" = "laurence"
End With
'Private Sub form_load()
Screen.MousePointer = vbHourglass
CRViewer91.ReportSource = Report
CRViewer91.ViewReport
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Resize1()
CRViewer91.Top = 0
CRViewer91.Left = 0
CRViewer91.Height = ScaleHeight
CRViewer91.Width = ScaleWidth
End Sub
Private Sub dirDialog_Change()
filDialog.Path = dirDialog.Path
End Sub
Private Sub drvDialog_Change()
drivelist.Drive "c:" Or "e:"
dirDialog.Path = drvDialog.Drive
End Sub
Private Sub filDialog_Click()
txtFilename.Text = filDialog.FileName
End Sub
Private Sub filDialog_Change()
Me.Caption = "Dialog Box - [" & filDialog.Path & "]"
End Sub
I am really new in programming with VB. I would like to run a Crystal reports from a VB form after the user has selected the report he wants to run. I do not know why, but I cannot find which command I have to run. I tried the SHELL command but it looks like it is only working with an .EXE file.
Anyone could help me?
Here is the code I made.
Public strMessage As String
Private Sub File1_Click()
drivelist.Drive = "c:"
End Sub
Private Sub cmdCancel_Click()
MsgBox "CANCELLED"
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim strMessage
strMessage = "Drive: " & drvDialog.Drive
strMessage = strMessage & vbCr & "Path: " & dirDialog.Path
strMessage = strMessage & vbCr & "Filename: " & filDialog.FileName
strMessage = strMessage & vbCr & "The lot: "
If Right(filDialog.Path, 1) = "\" Then
strMessage = filDialog.Path & filDialog.FileName
Else
strMessage = filDialog.Path & "\" & filDialog.FileName
End If
MsgBox strMessage
'ret = Shell(strMessage, 1)
'Instead of running this report.exe, I would like to run a .RPT file
Unload Me
End Sub
Private Sub Form_Load1()
Dim crApplication As New CRAXDRT.Application
Dim Report As CRAXDRT.Report
Set Report = crApplication.OpenReport("C:\activity.rpt"
'Set Report = crApplication.OpenReport("strMessage"
With Report.Database.Tables(1).ConnectionProperties
.Item("DSN" = "I"
.Item("Database" = "I"
.Item("User ID" = "laurence"
.Item("Password" = "laurence"
End With
'Private Sub form_load()
Screen.MousePointer = vbHourglass
CRViewer91.ReportSource = Report
CRViewer91.ViewReport
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Resize1()
CRViewer91.Top = 0
CRViewer91.Left = 0
CRViewer91.Height = ScaleHeight
CRViewer91.Width = ScaleWidth
End Sub
Private Sub dirDialog_Change()
filDialog.Path = dirDialog.Path
End Sub
Private Sub drvDialog_Change()
drivelist.Drive "c:" Or "e:"
dirDialog.Path = drvDialog.Drive
End Sub
Private Sub filDialog_Click()
txtFilename.Text = filDialog.FileName
End Sub
Private Sub filDialog_Change()
Me.Caption = "Dialog Box - [" & filDialog.Path & "]"
End Sub