Stop macro when time is <xx:xx

  • Thread starter Thread starter Siritl via AccessMonster.com
  • Start date Start date
S

Siritl via AccessMonster.com

I have a macro that loops 3 forms in Access. I would like to write a code
preferabelly in VB that stops these macros when time reaches 18.00. I have
tried something like this, but it seems like Access ignores the code:

Private Sub Skjema1_BeforeUpdate(Cancel As Integer)

If Time <= "18:00" Then
Run macro

Else
Close Form

End If

End Sub
 
IF Time() <= #18:00:00# THEN

Dates and times are delimited using # marks not " marks.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Ok, thank you!
But the code still doesn't work. Do you know what I can write to stop the
macro from running?

John said:
IF Time() <= #18:00:00# THEN

Dates and times are delimited using # marks not " marks.
I have a macro that loops 3 forms in Access. I would like to write a code
preferabelly in VB that stops these macros when time reaches 18.00. I have
[quoted text clipped - 11 lines]
 
If you are executing the macro from some other place than this code snippet,
you will have to modify the macro. Since I almost never do a macro I have
no idea how you could do that.

In the macro you should be able to use a condition to run or not run a macro

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Siritl via AccessMonster.com said:
Ok, thank you!
But the code still doesn't work. Do you know what I can write to stop the
macro from running?

John said:
IF Time() <= #18:00:00# THEN

Dates and times are delimited using # marks not " marks.
I have a macro that loops 3 forms in Access. I would like to write a code
preferabelly in VB that stops these macros when time reaches 18.00. I
have
[quoted text clipped - 11 lines]
 
Back
Top