Crystal reports

S

slinky

Thanks in advance... I have a main form which I have Menu items for
users to choose reports to run. When the user chooses a report another
form pops up - on there is a combobox from which the user chooses one
of five items, each calling a different report, and an OK button and a
Cancel button. Below is my code so far from my main form:

Private Sub mnuInsuranceTypes_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles mnuInsuranceTypes.Click
Dim report As CrystalDecisions.CrystalReports.Engine.ReportDocument
report = New
CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim frmOpts As frmReportOpts9 = New frmReportOpts9

If frmOpts.cboProductType.SelectedValue = "Medical" Then
Global.Crystal(report, "\Health.rpt")
Me.Cursor.Current = Cursors.WaitCursor
frmOpts.Dispose()
Dim f As New frmViewer
f.CrystalReportViewer.ReportSource = report
f.Show()
f = Nothing
Me.Show()
Me.Cursor.Current = Cursors.Default

(there are four additional blocks of code for the other "Selected
Values")

My question is how can I insert above a line of code that not only
handles the combobox "frmOpts.cboProductType.SelectedValue" but also
the "OK" button?

In pseudo code "If Combobox = Medical AND OK button = pressed, then
run report"
 
T

Terry

Why not just exit the sub if the user hit cancel. Then in the rest of the
sub you know he hit ok.

If frmOpts.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
Exit Sub
End If
 
S

slinky

Thanks... I tried your code (first block) but I may have some logic
issues. In my frmReportOpts from which the user chooses an product
type I have deleted any code for the combobox, the Yes, and the No
buttons. I tried the below (second block) also which got the
frmreportOpts to launch but the report viewer for CR did not. Here is
my basic code for the frmMain.(Under the properties for frmReportOpts
I have AcceptButton and CancelButton set to 'none':

Private Sub mnuInsuranceTypes_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles mnuInsuranceTypes.Click

Dim frmOpts As frmReportOpts = New frmReportOpts

If frmOpts.ShowDialog() = Windows.Forms.DialogResult.Cancel
Then
Exit Sub
End If


Dim report As
CrystalDecisions.CrystalReports.Engine.ReportDocument
report = New
CrystalDecisions.CrystalReports.Engine.ReportDocument

If frmOpts.cboProductType.SelectedValue = "Medical" Then
Global.Crystal(report, "\Health.rpt")
Me.Cursor.Current = Cursors.WaitCursor
frmOpts.Dispose()
Dim f As New frmViewer
f.CrystalReportViewer.ReportSource = report
f.Show()
f = Nothing
Me.Show()
Me.Cursor.Current = Cursors.Default

'ElseIf frmOpts.cboProductType.SelectedValue = "Dental"
Then
'***** OMITTED CODE FOR SIMPLIFICATION AND INTITIAL TEST
*****
End If

End If

End Sub
______________________________________________________________

Private Sub mnuInsuranceTypes_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles mnuInsuranceTypes.Click

Dim frmOpts As frmReportOpts = New frmReportOpts

If frmOpts.ShowDialog() = DialogResult.OK Then

Dim report As
CrystalDecisions.CrystalReports.Engine.ReportDocument
report = New
CrystalDecisions.CrystalReports.Engine.ReportDocument

If frmOpts.cboProductType.SelectedValue = "Medical" Then
Global.Crystal(report, "\Health.rpt")
Me.Cursor.Current = Cursors.WaitCursor
frmOpts.Dispose()
Dim f As New frmViewer
f.CrystalReportViewer.ReportSource = report
f.Show()
f = Nothing
Me.Show()
Me.Cursor.Current = Cursors.Default

'ElseIf frmOpts.cboInsuranceType.SelectedValue = "Dental"
Then
'***** OMITTED CODE FOR SIMPLIFICATION AND INTITIAL TEST
*****
End If

End If
 
T

Terry

So, have you put a break point in the routine to figure out what is going on?
Is the :

If frmOpts.cboProductType.SelectedValue = "Medical" Then

returning True?

The code in the block should at least display the form, provided that the If
is true. Sure you got your combobox properly configured?
 
S

slinky

I put a breakpoint there and ran the app stopping at the point after
choosing "Medical", then looked in the locals and autos windows and
moused-over the breakpoint line, but didn't see any value.
 
T

Terry

if putting the mouse over ...
frmOpts.cboProductType.SelectedValue
does not show you the value, then type into the immediate window ...

?frmOpts.cboProductType.SelectedValue

and find out what value the selectedvalue property is returning.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top