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

Run Code automatically 10 secs after opening Access

Status
Not open for further replies.

AndrewCorkery

Technical User
Oct 16, 2002
21
0
0
AU
Hi,

I need to get Access to run some code after opening the Application which will be done by the Windows Scheduled Tasks.

Ideally I would like a MsgBox to pop up after the application has opened, giving the user 10secs to cancel the macros from running- ie when the application is opened by the user and not the windows Scheduled Tasks.

Thanks

Andrew
 
Create a startup form to be loaded when the application is open (Tools-Startup menu or AutoExec macro).
Timer interval: 1000 (1 second)
Create a text box (SecondsToStart)
Create a command button (butCancel)
Paste the following code into the form's module:

Private Sub butCancel_Click()
DoCmd.Close
End Sub

Sub Form_Timer()
Static CountSeconds As Integer
Me("SecondsToStart") = 10 - CountSeconds
If Me("SecondsToStart") = 0 Then
Me.TimerInterval = 0
'Call whatever code here, then exit the application
DoCmd.Close ' or DoCmd.Quit
Else
CountSeconds = CountSeconds + 1
End If
End Sub

Good luck
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top