Results 1 to 6 of 6
  1. #1
    karanvemuri is offline Advanced Beginner
    Windows Vista Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    56

    Macro Help!

    hey guys,

    I have a macro which sends a report from Access, i used the Scheduled task to run the macro on a specific time everday. i Placed the below code in the Timer() Event of the main form. the macro is running fine but the reports are being sent twice.???? Advise needed




    Static intCounter As Integer
    Private Sub Form_Timer()
    If intCounter > 1 Then
    Me.TimerInterval = 0
    DoCmd.Quit
    Else
    DoCmd.RunMacro "mcrTest"
    End If

    intCounter = intCounter + 1
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I suspect the Integer variable is starting at 0, so it runs at 0 and 1. If you're using Scheduled Tasks, why the timer? I would have the process run when the db opens and then quit after.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    karanvemuri is offline Advanced Beginner
    Windows Vista Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    56
    i never opted for a scheduled task before,is there a way that i can run the macro at a specific time everyday automaticaly ??

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I'd create an mdb/accdb that does your task and then quits. Then I'd call that from Windows Scheduled Tasks on your desired schedule. If you rename your macro "autoexec" it will run when the db opens. Add a Quit to the end of it and you should be good to go.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    karanvemuri is offline Advanced Beginner
    Windows Vista Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    56
    Thanks for that mate, but the problem i have is I want the Macro to run automatically when the DB is open,its like when the agent finishes the work at say 11 PM and the Database is still open I want a macro to run automaticaly to send the report at 11:05 PM,everyday...can i do this without the Task Scheduler? where i can specify the Criteria in the macro itself and run it with a timer event??

    Hope i made myself clear

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Run your timer event, test for the current time being after 11:05pm. Once it is, set the timer interval to zero so it doesn't run any more, and run your macro.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Macro help
    By SFC in forum Access
    Replies: 4
    Last Post: 03-09-2011, 09:05 PM
  2. Help With Macro's
    By GDubbs780 in forum Programming
    Replies: 1
    Last Post: 02-25-2011, 11:43 AM
  3. Replies: 0
    Last Post: 01-12-2011, 12:43 PM
  4. VBA Macro
    By DSTR3 in forum Access
    Replies: 1
    Last Post: 11-30-2010, 11:42 AM
  5. MACRO help please
    By DianeG in forum Forms
    Replies: 2
    Last Post: 04-20-2010, 07:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums