Adding a delay before code continues

  • Thread starter Thread starter John Ortt
  • Start date Start date
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
 
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
 
Back
Top