Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

ACCESS 07 Report won't open

$
0
0
I built a database on my company network that only I use.

I've got a report, mrSO, I open with query defs in an onclick, cmdOUT
I run this everyday - until last Thursday when I did compact & repair before I closed out.
This report won't open anymore. Can anyone suggest what may have happened as the code was not changed at all? I ran analysis and compiled code but neither worked?
Here's the code...........
command button:
Code:

Private Sub cmdOUT_Click()
Dim DB As DAO.Database
Dim QDF1 As QueryDef
Dim where As Variant

Set DB = CurrentDb()

On Error Resume Next
DB.QueryDefs.Delete ("GoalsA")
On Error GoTo 0

where = where & " AND (IsNull([Unapplied]))"
where = where & " AND ([Salesrep1] Like '*" & [txtWCIGslmn] & "*' OR [SLMN2] Like '*" & [txtWCIGslmn] & "*' OR [SLMN3] Like '*" & [txtWCIGslmn] & "*')"
where = where & " AND ([BAL] Is Null OR [BAL] > 0)"
where = where & " AND ((([DUE]>Date())=0))"
where = where & " AND (IsNull([ICID]))"


Set QDF1 = DB.CreateQueryDef("GoalsA", "Select * From qryMainReport1" & (" where " & Mid(where, 6) & ";"))
DoCmd.OpenReport "mrSO", acViewPreview


End Sub

I know that the onclick is working because DoCmd.OpenReport is triggering...if you see below I have a function Report_Open that opens 2 queries. Those open, then access shows Formatting and Running Query at bottom right, but the report mrSO doesn't open......the 2 queries close and then I'm back to my form with cmdOUT?

I can't identify why there is a hangup now when it tries to open, and why it is jumping to Report_Close which triggers the queries to close?

Any suggestions to fix or change would be greatly appreciated! (Although, this worked for me as is since I created it)

report:
Code:

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
    If Me.srFAKES.Report.HasData Then
        Me.srFAKES.Visible = True
        End If
            If Me.SlmnOutstandingCM.Report.HasData Then
                Me.SlmnOutstandingCM.Visible = True
                End If
     
End Sub
               
   
Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)
    If Me.srCPO.Report.HasData Then
        Me.srCPO.Visible = True
        Else
        Me.srCPO.Visible = False
        End If
            If Me.srNOTES.Report.HasData Then
            Me.srNOTES.Visible = True
            Else
            Me.srNOTES.Visible = False
            End If
                If Me.Slmn_OutstandingCI.Report.HasData Then
                Me.Slmn_OutstandingCI.Visible = True
                Else
                Me.Slmn_OutstandingCI.Visible = False
                End If
                    If Me.SlmnOutstandingCO.Report.HasData Then
                    Me.SlmnOutstandingCO.Visible = True
                    Else
                    Me.SlmnOutstandingCO.Visible = False
                    End If
End Sub

Private Sub Report_Close()
DoCmd.Close acQuery, "TotalsA"
DoCmd.Close acQuery, "GrandTotalsA"
End Sub

Private Sub Report_Open(Cancel As Integer)
Dim DBSO1 As DAO.Database
Dim DBSO2 As DAO.Database
Dim QSO1 As QueryDef
Dim QSO2 As QueryDef
Dim where As Variant

Set DBSO1 = CurrentDb()
Set DBSO2 = CurrentDb()

On Error Resume Next
DBSO1.QueryDefs.Delete ("TotalsA")
DBSO2.QueryDefs.Delete ("GrandTotalsA")
On Error GoTo 0

where = where & " AND ([Salesrep1] Like '*" & [Forms]![WCIGChooser]![txtWCIGslmn] & "*' OR [SLMN2] Like '*" & [Forms]![WCIGChooser]![txtWCIGslmn] & "*' OR [SLMN3] Like '*" & [Forms]![WCIGChooser]![txtWCIGslmn] & "*')"
where = where & " AND ((([DUE]>Date())=0))"

Set QSO1 = DBSO1.CreateQueryDef("TotalsA", "Select * From qryMainReport2" & (" where " & Mid(where, 6) & ";"))
DoCmd.OpenQuery "TotalsA"
Set QSO2 = DBSO2.CreateQueryDef("GrandTotalsA", "Select * From qryMainReport2" & (" where " & Mid(where, 6) & ";"))
DoCmd.OpenQuery "GrandTotalsA"
End Sub


Viewing all articles
Browse latest Browse all 13329

Trending Articles