Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Report and VB6 Interface Problem

Status
Not open for further replies.

pungy

Instructor
Aug 5, 2007
71
US
VB 6 Enterprise Edition, CR 11 Professional Edition

Within a VB6 application, I have a form which contains Option Buttons in a Control Array. Each option button is calling a differerent report (each report was designed in CR11).
Here is the Option click event:
Code:
Private Sub optReport_Click(Index As Integer)
Unload frmCRPrint
    DoEvents
Select Case Index
Case 1  'List Games All Weeks
    Call GameAllList
    frmCRPrint.Show vbModal
    optReport(1).Value = False
Case 2  'List a Game Specific Week
    fraChooseWeek.Visible = True
    Game = True
Case 3  'List ALL Players
    Call PlayerAllList
    frmCRPrint.Show vbModal
    optReport(3).Value = False
 Case 4  'List Pool Players for a Specific Week
    fraChooseWeek.Visible = True
    Player = True
End Select
If Game Then
    cboWeekNumber.SetFocus
    Exit Sub
End If
optReport(1).Value = False
frmReportMenu.optReport(0).SetFocus
End Sub
Note Case 2. When it does the End Select, it puts focus on a combo box call cboWeekNumber. The user enters information then in cboWeeknumber_LostFocus,this code is executed;
Code:
Private Sub cboWeekNumber_LostFocus()
HoldWeekNumber = Val(cboWeekNumber.Text)
If Game Then
    SQL = "Select * from WeeklyGame where WeekNumber = " & Val(cboWeekNumber.Text) & ";"
    Set rstWeeklyGame = pconSports.Execute(SQL)
    If rstWeeklyGame.EOF And rstWeeklyGame.BOF Then
        MsgBox ("There are no Games for Week " & Val(cboWeekNumber.Text) & ".")
        fraChooseWeek.Visible = False
        optReport(2).Value = False
        frmReportMenu.optReport(0).SetFocus
        Exit Sub
    End If
    fraChooseWeek.Visible = False
    ReportName = "ListSpecificGames.rpt"
    frmCRPrint.Show vbModal
    optReport(2).Value = False
    Game = False
    frmReportMenu.optReport(0).SetFocus
    Exit Sub
End If
.
.
.
End Sub

What's happening is this:When it executes the frmCRPrint.Show vbModal, frmCRPrint loads, goes to the Form_Resize event but NEVER goes to the FORM_ACTIVATE event.
frmCRPrint:
Code:
Option Explicit
Private Sub cmdReturn_Click()
Unload Me
End Sub

Private Sub Form_Activate()

Set craxreport = craxapp.OpenReport(ReportPath & "\" & ReportName)
    If ReportName = "ListAllGames.rpt" Then
        GoTo DoReport
    ElseIf ReportName = "ListSpecificGames.rpt" Then
        craxreport.FormulaSyntax = crCrystalSyntaxFormula
        craxreport.RecordSelectionFormula = "{WeeklyGame.WeekNumber} = " & HoldWeekNumber
    ElseIf ReportName = "ListAllPlayers.rpt" Then
        GoTo DoReport
        ElseIf ReportName = "ListSpecificPlayers.rpt" Then
        craxreport.FormulaSyntax = crCrystalSyntaxFormula
        craxreport.RecordSelectionFormula = "{GamePlayers.WeekNumber} = " & HoldWeekNumber

    End If

DoReport:
    DoEvents
' ==============================================================================
    Screen.MousePointer = vbHourglass
    crViewer1.Refresh
    crViewer1.Zoom "100"
    While crViewer1.IsBusy
        DoEvents
    Wend
    crViewer1.ReportSource = craxreport
    crViewer1.Refresh
    crViewer1.ViewReport
    crViewer1.Refresh
    Set craxreport = Nothing
    Screen.MousePointer = vbDefault
End Sub

Private Sub Form_Load()
Set craxapp = CreateObject("Crystalruntime.application.11")
End Sub

Private Sub Form_Resize()
Me.Height = Screen.Height
Me.Width = Screen.Width
crViewer1.Top = 0
crViewer1.Height = Me.ScaleHeight
crViewer1.Width = Me.ScaleWidth
cmdReturn.Left = (crViewer1.Left + crViewer1.Width) - (cmdReturn.Width + 400)
cmdReturn.Top = crViewer1.Top
frmCRPrint.Refresh
End Sub


Please, can you tell me what I am doing wrong?
Thanks,
Sam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top