Hello everyone,
I have a strange problem. I'm trying to run the following code:
Code:
If rpNameNu <> rpName Then Me!KnopPrint.Visible = False
Me!KnopPDF.Visible = False
Me!KnopSent.Visible = False
DoCmd.OutputTo acOutputReport, rpNameNu, acFormatPDF, , no, , , acExportQualityPrint
End If
This needs to run a second after the report is open. But when I insert the code into On Load property, or the On Open property it won't work
Simply because the report is not jet open..
When I put the code in the On Current property, and open the report, and click somewhere random, the code does work!
Does someone know how I can let it run smooth?
I also tryed these functions to delay the export to pdf functionality:
Code:
Option Compare Database
Public Function Pause(NumberOfSeconds As Variant)
On Error GoTo Error_GoTo
Dim PauseTime As Variant
Dim Start As Variant
Dim Elapsed As Variant
PauseTime = NumberOfSeconds
Start = Timer
Elapsed = 0
Do While Timer < Start + PauseTime
Elapsed = Elapsed + 1
If Timer = 0 Then
' Crossing midnight
PauseTime = PauseTime - Elapsed
Start = 0
Elapsed = 0
End If
DoEvents
Loop
Exit_GoTo:
On Error GoTo 0
Exit Function
Error_GoTo:
Debug.Print Err.Number, Err.Description, Erl
GoTo Exit_GoTo
End Function
and:
Code:
Option Compare Database
Option Explicit
Private Declare Sub sapiSleep Lib "kernel32" _
Alias "Sleep" _
(ByVal dwMilliseconds As Long)
Sub sSleep(lngMilliSec As Long)
If lngMilliSec > 0 Then
Call sapiSleep(lngMilliSec)
End If
End Sub
Both without succes.
Thanks in advance.