Brief history:
I have created a form in VB which gives Users a chance to select the Userids they wish to report on. Their selection is collected in a listbox. I use a loop to create the record selection. I then want to pass this information to the report viewer, log on to the server, select the new records, and view the report.
I am very new to VB and am trying my best to use the resources here as well as book suggestions made here. I am having one heck of a time putting it all together.
I have created the record selection list, I have been able to show the form viewer.
The code I have for creating the record selection. It does show what I created in the msgbox and from what I can tell, it looks correct:
Private Sub cmdRun_Click()
Dim crxapplication As New CRAXDRT.Application
Dim Report As New CrystalReport2
Dim iTotalSelected As Integer
Dim strSelUserid As String
Dim strParameterList As String
strParameterList = "{W20U999S.ENDSTATCD} in [""DECLINE"", ""DECLINED "", ""UWCONDISS "", ""UWISSUE ""] AND " _
& "{W20U999S.ENDUSERID} in ["
iTotalSelected = lstUndNamesR.ListCount
For i = 0 To (iTotalSelected - 1)
strSelUserid = lstUndNamesR.List(i)
If iTotalSelected = 1 Or (i = iTotalSelected - 1) Then
strParameterList = strParameterList & """" & strSelUserid & """" & "]"
Else
strParameterList = strParameterList & """" & strSelUserid & """" & ", "
End If
Next
MsgBox strParameterList
Report.RecordSelectionFormula = strParameterList
frmViewer.Show
End Sub
******************* form viewer below *******************
Dim Application As CRAXDRT.Application
Dim Report As New CrystalReport2
Private Sub form_load()
Screen.MousePointer = vbHourglass
Report.Database.Tables.Item(1).SetLogOnInfo test, test, test, test
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
End Sub
I keep getting 'Server has not yet been opened'. I think I am close to getting an answer, but have not quite got it.
Can anyone give me suggestions?
Thank you in advance for your help.
Jody
I have created a form in VB which gives Users a chance to select the Userids they wish to report on. Their selection is collected in a listbox. I use a loop to create the record selection. I then want to pass this information to the report viewer, log on to the server, select the new records, and view the report.
I am very new to VB and am trying my best to use the resources here as well as book suggestions made here. I am having one heck of a time putting it all together.
I have created the record selection list, I have been able to show the form viewer.
The code I have for creating the record selection. It does show what I created in the msgbox and from what I can tell, it looks correct:
Private Sub cmdRun_Click()
Dim crxapplication As New CRAXDRT.Application
Dim Report As New CrystalReport2
Dim iTotalSelected As Integer
Dim strSelUserid As String
Dim strParameterList As String
strParameterList = "{W20U999S.ENDSTATCD} in [""DECLINE"", ""DECLINED "", ""UWCONDISS "", ""UWISSUE ""] AND " _
& "{W20U999S.ENDUSERID} in ["
iTotalSelected = lstUndNamesR.ListCount
For i = 0 To (iTotalSelected - 1)
strSelUserid = lstUndNamesR.List(i)
If iTotalSelected = 1 Or (i = iTotalSelected - 1) Then
strParameterList = strParameterList & """" & strSelUserid & """" & "]"
Else
strParameterList = strParameterList & """" & strSelUserid & """" & ", "
End If
Next
MsgBox strParameterList
Report.RecordSelectionFormula = strParameterList
frmViewer.Show
End Sub
******************* form viewer below *******************
Dim Application As CRAXDRT.Application
Dim Report As New CrystalReport2
Private Sub form_load()
Screen.MousePointer = vbHourglass
Report.Database.Tables.Item(1).SetLogOnInfo test, test, test, test
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
End Sub
I keep getting 'Server has not yet been opened'. I think I am close to getting an answer, but have not quite got it.
Can anyone give me suggestions?
Thank you in advance for your help.
Jody