If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
AutoExec?
Hi I have an AutoExec macro that starts a macro that will create an email and
I only want this to happen once a week. (This is opened by the Schedule Tasks) But the AutoExec will kick start the email every time the program is opened by a User. Is there en way I can add code to check if and email has gone out to not send another one??? Jo |
#2
|
|||
|
|||
AutoExec?
hi Jo,
jo wrote: Hi I have an AutoExec macro that starts a macro that will create an email and I only want this to happen once a week. (This is opened by the Schedule Tasks) But the AutoExec will kick start the email every time the program is opened by a User. Is there en way I can add code to check if and email has gone out to not send another one??? Yes. First of all you need to modify your scheduled task. You need to change the call to your .mdb file to "C:\pathToMsAccess\MSACCESS.EXE" "C:\pathTo\Database.mdb" /cmd SendEMail Then you need a function in a standard module: Public Function SendEMail() As Boolean 'Test the value from the /cmd parameter. If Command() = "SendEMail" Then DoCmd.RunMacro "yourMacroName" End If End Function Use this function in your AutoExec macro with then RunCode action. Now the program will only send the e-mail when started by the scheduled task. mfG -- stefan -- |
#3
|
|||
|
|||
AutoExec?
Hi Steve I have done the following but i am getting an error Expression you
entered has a function name that Mydatabase can't find? I am doing something wrong??: Made a macro called AutoExec; Runcode; Function Name SendEmail() and the code: Option Compare Database Public Function SendEMail() As Boolean 'Test the value from the /cmd parameter. If Command() = "SendEMail" Then DoCmd.RunMacro "Checker" End If End Function "Stefan Hoffmann" wrote: hi Jo, jo wrote: Hi I have an AutoExec macro that starts a macro that will create an email and I only want this to happen once a week. (This is opened by the Schedule Tasks) But the AutoExec will kick start the email every time the program is opened by a User. Is there en way I can add code to check if and email has gone out to not send another one??? Yes. First of all you need to modify your scheduled task. You need to change the call to your .mdb file to "C:\pathToMsAccess\MSACCESS.EXE" "C:\pathTo\Database.mdb" /cmd SendEMail Then you need a function in a standard module: Public Function SendEMail() As Boolean 'Test the value from the /cmd parameter. If Command() = "SendEMail" Then DoCmd.RunMacro "yourMacroName" End If End Function Use this function in your AutoExec macro with then RunCode action. Now the program will only send the e-mail when started by the scheduled task. mfG -- stefan -- |
#4
|
|||
|
|||
AutoExec?
Using Stefan's method, you do not need the autoexec macro.
The important part is using the command line option he showed you. The /cmd SendEMail tells Access to run the function named SendEmail. Also, be sure your function is in a Standard Module and that the function and the module do not have the same name. If you name a function or sub in a module the same name as the module, it will cause problems. -- Dave Hargis, Microsoft Access MVP "jo" wrote: Hi Steve I have done the following but i am getting an error Expression you entered has a function name that Mydatabase can't find? I am doing something wrong??: Made a macro called AutoExec; Runcode; Function Name SendEmail() and the code: Option Compare Database Public Function SendEMail() As Boolean 'Test the value from the /cmd parameter. If Command() = "SendEMail" Then DoCmd.RunMacro "Checker" End If End Function "Stefan Hoffmann" wrote: hi Jo, jo wrote: Hi I have an AutoExec macro that starts a macro that will create an email and I only want this to happen once a week. (This is opened by the Schedule Tasks) But the AutoExec will kick start the email every time the program is opened by a User. Is there en way I can add code to check if and email has gone out to not send another one??? Yes. First of all you need to modify your scheduled task. You need to change the call to your .mdb file to "C:\pathToMsAccess\MSACCESS.EXE" "C:\pathTo\Database.mdb" /cmd SendEMail Then you need a function in a standard module: Public Function SendEMail() As Boolean 'Test the value from the /cmd parameter. If Command() = "SendEMail" Then DoCmd.RunMacro "yourMacroName" End If End Function Use this function in your AutoExec macro with then RunCode action. Now the program will only send the e-mail when started by the scheduled task. mfG -- stefan -- |
#5
|
|||
|
|||
AutoExec?
Hi guys thanks for yr replys most appreciated! After reading yr reply I can
understand how important the /cmd SendEmail is but not sure where abouts on the Scheduler task I put it? I keep getting error: "The command line you used to start Access contains an option that Microsoft Office Access doesnt reckonize" . (I have windows vista) . And this is what I have put in the Action part: Program Box: "D:\Central Gauge Calibration Database2.mdb" Add Argument box: Menu\Programs\Microsoft Office\MSACCESS.EXE” “C: \Users\Joanne Blankley\Desktop\Central Gauge Calibration Database2”/cmd SendEmail Sorry to be a pain but I am new Schedule Task. "Klatuu" wrote: Using Stefan's method, you do not need the autoexec macro. The important part is using the command line option he showed you. The /cmd SendEMail tells Access to run the function named SendEmail. Also, be sure your function is in a Standard Module and that the function and the module do not have the same name. If you name a function or sub in a module the same name as the module, it will cause problems. -- Dave Hargis, Microsoft Access MVP "jo" wrote: Hi Steve I have done the following but i am getting an error Expression you entered has a function name that Mydatabase can't find? I am doing something wrong??: Made a macro called AutoExec; Runcode; Function Name SendEmail() and the code: Option Compare Database Public Function SendEMail() As Boolean 'Test the value from the /cmd parameter. If Command() = "SendEMail" Then DoCmd.RunMacro "Checker" End If End Function "Stefan Hoffmann" wrote: hi Jo, jo wrote: Hi I have an AutoExec macro that starts a macro that will create an email and I only want this to happen once a week. (This is opened by the Schedule Tasks) But the AutoExec will kick start the email every time the program is opened by a User. Is there en way I can add code to check if and email has gone out to not send another one??? Yes. First of all you need to modify your scheduled task. You need to change the call to your .mdb file to "C:\pathToMsAccess\MSACCESS.EXE" "C:\pathTo\Database.mdb" /cmd SendEMail Then you need a function in a standard module: Public Function SendEMail() As Boolean 'Test the value from the /cmd parameter. If Command() = "SendEMail" Then DoCmd.RunMacro "yourMacroName" End If End Function Use this function in your AutoExec macro with then RunCode action. Now the program will only send the e-mail when started by the scheduled task. mfG -- stefan -- |
Thread Tools | |
Display Modes | |
|
|