IsError()

I think you should stick to one thing. Either you try to fix the #Error problem or you show a blank report.

How does the report get opened, isn't it via a button? Behind that button there's code.

There is a macro behind the on click event of the button which initially opens the report in preview mode and subsequently also closes some other "objects"

Thanks again.

PS I think the blank report is a better option otherwise I have a lot of reports to change :(
 
Try converting the Macro to VBA code. Open the macro in design view and there should be a button in the menubar or ribbon that would Convert Macro to VBA.

NB: Try it on a backup copy first :)
 
Try converting the Macro to VBA code. Open the macro in design view and there should be a button in the menubar or ribbon that would Convert Macro to VBA.

NB: Try it on a backup copy first :)



Option Compare Database
'------------------------------------------------------------
' preview_a_subac
'
'------------------------------------------------------------
Function preview_a_subac()
On Error GoTo preview_a subac_Err
' preview a subac
DoCmd.OpenReport "a subac", acViewPreview, "", ""
' close indi ac/subac
DoCmd.Close acForm, "A"
' close all reports
DoCmd.Close acForm, "B"

preview_a subac_Exit:
Exit Function
preview_a subac_Err:
MsgBox Error$
Resume preview_a subac_Exit
End Function
 
You will still need to change every report because you open several reports from different locations (i.e. buttons located on different forms). Here's an amend to your code:
Code:
Option Compare Database
'------------------------------------------------------------
' preview_a_subac
'
'------------------------------------------------------------
Function preview_a_subac()
On Error GoTo preview_a subac_Err

    DoCmd.OpenReport "a subac", acViewDesign, , , acHidden

    If DCount("*", Trim(Reports("a subac").RecordSource)) = 0 Then
         docmd.close acreport, "a subac", acSaveNo
     Docmd.openreport "[B][COLOR=Red]NameOfBlankReport[/COLOR][/B]", acViewPreview
         MsgBox "No data available", , "No data available"
         Exit function
    End If

    ' preview a subac
    DoCmd.OpenReport "a subac", acViewPreview, "", ""
    ' close indi ac/subac
    DoCmd.Close acForm, "A"
    ' close all reports
    DoCmd.Close acForm, "B"

preview_a subac_Exit:
Exit Function
preview_a subac_Err:
MsgBox Error$
Resume preview_a subac_Exit
End Function
The bit in red needs to be changed.
 
Hi,

many thanks.

But I think this code will produce a message box.

I want the same report to appear but with a text on the reort which states that there is no data available.

Many thanks once again for your patience.
 
I think you should post your database and point to the problem report.
 
Many thanks once again. You have taught me quite a bit.

Cheers
 

Users who are viewing this thread

Back
Top Bottom