I would like to have the VBA module code below pause and then close a report. As is, I am getting an error message, when compiling, that "Constants, fixed-length strings, arrays, user-defined types and Declare statements not allowed as Public members of object modules". I guess I can split the Declaration Function and the subroutine into two scripts, and have the pause function call the close subroutine, right? Can someone give guidance please?
Code:
Option Compare Database
Declare Function Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Report_NoData(Cancel As Integer)
On Error GoTo HandleErr
Sleep (5000)
DoCmd.Close
ExitHere:
Exit Sub
HandleErr:
MsgBox "Error number " & Err.Number & ": " & Err.Description
Resume ExitHere
End Sub