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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Snapshot Not Working with Timer Event

Status
Not open for further replies.
Aug 17, 2007
5
0
0
US
I am working with an Access 2003 database. Since adding a timer event to check for idle time to a form, a custom toolbar button that creates a snapshot has stopped working properly. Until the first time the timer event procedure is run, the button works fine, but after that, it produces an error "The Object Type argument for the action or method is blank or invalid."

The button runs a macro which runs the action "OutputTo" with the following settings:
Object Type: Report
Object Name: (blank)
Output Format: Snapshot Format

The code for the timer procedure is:
Private Sub Form_Timer()
'************************************************* *********************
'* This timer event procedure will shut down the application
'* after a specified number of minutes of inactivity. Inactivity
'* is measured based on how long a control remains the ActiveControl.
'************************************************* *********************
Dim sngElapsedTime As Single
Dim ctlNew As Control
Dim currObject As String
On Error Resume Next

Set ctlNew = Screen.ActiveControl
If Err <> 0 Then
'* No activecontrol
sngElapsedTime = Timer - sngStartTime
Err.Clear
Else
If ctlNew.Name = "InactiveShutDownCancel" Then
'* The warning form has appeared, and the cancel button
'* is the active control
sngElapsedTime = Timer - sngStartTime
Else
If ctlNew.Name = ctlSave.Name Then
'* Still at same control
sngElapsedTime = Timer - sngStartTime
Else
'* Some change has occured, we're at a new control
Set ctlSave = ctlNew
resetTimer
End If
If Err <> 0 Then
Set ctlSave = Screen.ActiveControl
End If
End If
End If
Err.Clear

On Error GoTo Err_Path

Set ctlNew = Nothing

If sngElapsedTime > (intMinutesUntilShutDown * 60) Then ' First interval has passed; present idle warning.
DoCmd.OpenForm "frmInactiveShutDown", , , , , , sngElapsedTime & "|" & sngStartTime & "|" & intMinutesUntilShutDown & "|" & intMinutesWarningAppears
End If

Exit Sub
Err_Path:
MsgBox (ErrorLogRuntime(Error$, Screen.ActiveForm.Name, Screen.ActiveControl.Name))

Exit_Section:
End Sub



Any help is most appreciated.
 
For anyone who's interested, I solved my problem eventually by using code in place of the macro as follows:
Code:
    Dim reportName As String

    reportName = Application.CurrentObjectName
    
    On Error Resume Next
    DoCmd.OutputTo acOutputReport, reportName, acFormatSNP, , True

It seems obvious to me that this shouldn't work, but it sure does. My project is all set, now, but if anyone has any ideas why this works when my original attempt (below) doesn't, I'm very curious and would love to hear about it:
Code:
    DoCmd.OutputTo acOutputReport, , acFormatSNP, , True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top