RE Need help with module 
Author Message
 RE Need help with module

See the form's Timer event.  If you leave a form open, set
the timer to like 30000 (30 seconds) and test for the
desired time (to minutes only) to fire your code.

Private Sub Form_Timer()
    Static boolFired As Boolean
    If Format(Time, "h:mm AM/PM") = "12:06 PM" And
boolFired = False Then
        MsgBox "Once a day alarm"
        boolFired = True
    ElseIf Format(Time, "h:mm AM/PM") <> "12:06 PM" Then
        boolFired = False
    End If
End Sub

Quote:
>-----Original Message-----
>I am trying to setup a module which will run a macro at a
>certain time of the day.  If this is possible, I would
>like to run this every week only on Monday.  Can anyone
>help me. I'm sorry, I've never written anything in access
>before.  I'm hoping this will run if the database is open.

>Thanks for your help!  Below is what I have attempted to
>create.

>Sub run_macro()
>Let x = 1
>Do While x = 1
>Dim MyTime
>MyTime = time    ' Return current system time.
>If MyTime = "7:45 AM" Then
>DoCmd.RunMacro "maketable"
>End If
>Loop
>End Sub

>.



Sun, 08 May 2005 04:08:26 GMT  
 RE Need help with module
Check this function in the help: 'Weekday' to determine what day it is.
Then you should retrieve the time. The timer event could be used, however, I
would set it programmatically\via code: check what time it is, then your
'firing time' and then set the timer event to the difference of these two
times: now it will be triggered only once, instead of every 30 seconds as
Media Lint wrote.

Your macro can be called by: DoCmd.RunMacro "maketable"


Quote:
> See the form's Timer event.  If you leave a form open, set
> the timer to like 30000 (30 seconds) and test for the
> desired time (to minutes only) to fire your code.

> Private Sub Form_Timer()
>     Static boolFired As Boolean
>     If Format(Time, "h:mm AM/PM") = "12:06 PM" And
> boolFired = False Then
>         MsgBox "Once a day alarm"
>         boolFired = True
>     ElseIf Format(Time, "h:mm AM/PM") <> "12:06 PM" Then
>         boolFired = False
>     End If
> End Sub

> >-----Original Message-----
> >I am trying to setup a module which will run a macro at a
> >certain time of the day.  If this is possible, I would
> >like to run this every week only on Monday.  Can anyone
> >help me. I'm sorry, I've never written anything in access
> >before.  I'm hoping this will run if the database is open.

> >Thanks for your help!  Below is what I have attempted to
> >create.

> >Sub run_macro()
> >Let x = 1
> >Do While x = 1
> >Dim MyTime
> >MyTime = time    ' Return current system time.
> >If MyTime = "7:45 AM" Then
> >DoCmd.RunMacro "maketable"
> >End If
> >Loop
> >End Sub

> >.



Sun, 08 May 2005 09:10:15 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. HELP!! Student needs help with module/form error

2. VBA beginner needs help with Module

3. Need Help with Modules

4. Help Needed Editing a Module

5. Help needed with Module Listing

6. I really need help with writing a module

7. First Module, Need Help

8. Need help with a Form/Module - Workgroup stuff

9. Newbie Module User Needs Help!?!

10. Need Help Writting a VBA Module In Access 87

11. Need help getting started on first module

12. Need help coding simple module in Access 97

 

 
Powered by phpBB® Forum Software