Adding a delay before code continues

J

John Ortt

I am using the following code to check who is accessing the database and log
them out if they are not me.
I would like to insert a delay before Access shuts down after the
unauthorised user closes the message box, could anybody assist me in doing
this please.

Thankyou,

John.

Code follows:

Function Logoffcode()
Static MsgSent As Integer
Dim Logoff As Integer
Dim LO As Boolean

Set Db = CurrentDb() 'Note the table must be attached
'for CurrentDb() to work or use a
'connect string to the server db.

UserName = [Forms]![MainMenu].[UserBox]

If UserName = "B643603" Then
MsgBox "Hi"
Else
MsgBox "The Application will now shut down."
Application.Quit
'Log them off

End If

End Function
 
S

StCyrM

Good morning

You can use the following to make the application ' sleep ' for a bit..

Hope this helps.

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

'Sleep 4000 ---> 4 second delay

in your application:
If UserName = "B643603" Then
MsgBox "Hi"
Else
MsgBox "The Application will now shut down."

Sleep 4000 ' 4 second delay
Application.Quit
'Log them off

End If

Best Regards

Maurice St-Cyr
Micro Systems Consultants, Inc.


I am using the following code to check who is accessing the database and log
them out if they are not me.
I would like to insert a delay before Access shuts down after the
unauthorised user closes the message box, could anybody assist me in doing
this please.

Thankyou,

John.

Code follows:

Function Logoffcode()
Static MsgSent As Integer
Dim Logoff As Integer
Dim LO As Boolean

Set Db = CurrentDb() 'Note the table must be attached
'for CurrentDb() to work or use a
'connect string to the server db.

UserName = [Forms]![MainMenu].[UserBox]

If UserName = "B643603" Then
MsgBox "Hi"
Else
MsgBox "The Application will now shut down."
Application.Quit
'Log them off

End If

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Forcing a screen refresh before code continues 3
Timer event not working. 4
loop form 1
LogUsersOff 0
LogUsersOff 0
Holiday day tracking 2
HELP! VBA Code Stopping on Open 3
Refresh tables code 1

Top