A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

AutoExec?



 
 
Thread Tools Display Modes
  #1  
Old July 2nd, 2009, 11:55 AM posted to microsoft.public.access
Jo
external usenet poster
 
Posts: 508
Default 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  
Old July 2nd, 2009, 12:08 PM posted to microsoft.public.access
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default 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  
Old July 2nd, 2009, 01:09 PM posted to microsoft.public.access
Jo
external usenet poster
 
Posts: 508
Default 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  
Old July 2nd, 2009, 03:43 PM posted to microsoft.public.access
Klatuu
external usenet poster
 
Posts: 7,074
Default 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  
Old July 2nd, 2009, 06:41 PM posted to microsoft.public.access
Jo
external usenet poster
 
Posts: 508
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:57 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.