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  

Run code then repeat every 15 minutes



 
 
Thread Tools Display Modes
  #1  
Old April 25th, 2010, 09:59 AM posted to microsoft.public.access
Karren Lorr
external usenet poster
 
Posts: 19
Default Run code then repeat every 15 minutes

Hello

I am sorry to re-post this question but I can't get it to work after many
hours of trying and searching various websites for assistance.

I am trying to look to see if a text box on my form contains the string
"Found". If it does it will send an e mail (this section works fine). If it
does not then wait for 15 minutes and repeat the check to look for the string.

I can not get the code to wait and repeat.

I tried John Vinson's code
Me.Timer = 1000*60*15
Call Timer ' to have it "do something" the first time

but in this case I get the error "Method or Data Member not found" with the
Me.Time highlighted.

This is what I'm trying to accomplish (the e mail details have taken out for
this post)

Private Sub Form_Button_Click()
If Me.Found = "Found" Then
Call FnSafeSendEmail("emailaddress", "mailtitle", "mailbody", "", "", "")
DoCmd.Quit
Else
'wait 10 minutes and repeat, this is the section I need help with'
End If
End Sub

This small section of code is the last step in a quite complex set of codes.
All the rest of the process works fine and produces the desired results. It
is just this last section I am having problems with, repeating of the form’s
search of this text box.

Can anyone help with this please


  #2  
Old April 25th, 2010, 12:45 PM posted to microsoft.public.access
Peter Hibbs
external usenet poster
 
Posts: 871
Default Run code then repeat every 15 minutes

Karren,

Try this :-

Open the form's property sheet and click on the On Timer event and
then click the ... button (select Code in the pop-up form, if
necessary). In this event add the code below so that it looks
something like this :-

Private Sub Form_Timer()

If Me.Found = "Found" Then
Call FnSafeSendEmail("emailaddress", "mailtitle", "mailbody",
"", "", "")
DoCmd.Quit

End Sub

The Call command should all be on one line, of course.

In your button event you should add this :-

Private Sub Form_Button_Click()
Me.TimerInterval = 900000 '900,000 = 15 mins
End Sub

Note that the first test in the Timer event will not happen until 15
minutes has elapsed, if you want to check the Found field immediately
on clicking the button you can add the code in the Timer event to the
button event. Also, the form should be active all the time the timer
is running, if the form is closed then the timer will stop
(obviously). You could hide it, of course, if you don't need to see it
on screen.

If you need to stop the timer you can reset the TimerInterval property
to 0 but as the database shuts down when the test is True and the
timer expires, I guess you probably don't need this.

HTH

Peter Hibbs.


On Sun, 25 Apr 2010 01:59:01 -0700, Karren Lorr
wrote:

Hello

I am sorry to re-post this question but I can't get it to work after many
hours of trying and searching various websites for assistance.

I am trying to look to see if a text box on my form contains the string
"Found". If it does it will send an e mail (this section works fine). If it
does not then wait for 15 minutes and repeat the check to look for the string.

I can not get the code to wait and repeat.

I tried John Vinson's code
Me.Timer = 1000*60*15
Call Timer ' to have it "do something" the first time

but in this case I get the error "Method or Data Member not found" with the
Me.Time highlighted.

This is what I'm trying to accomplish (the e mail details have taken out for
this post)

Private Sub Form_Button_Click()
If Me.Found = "Found" Then
Call FnSafeSendEmail("emailaddress", "mailtitle", "mailbody", "", "", "")
DoCmd.Quit
Else
'wait 10 minutes and repeat, this is the section I need help with'
End If
End Sub

This small section of code is the last step in a quite complex set of codes.
All the rest of the process works fine and produces the desired results. It
is just this last section I am having problems with, repeating of the form’s
search of this text box.

Can anyone help with this please

  #3  
Old April 25th, 2010, 07:43 PM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Run code then repeat every 15 minutes

On Sun, 25 Apr 2010 01:59:01 -0700, Karren Lorr
wrote:

I tried John Vinson's code
Me.Timer = 1000*60*15
Call Timer ' to have it "do something" the first time

but in this case I get the error "Method or Data Member not found" with the
Me.Time highlighted.


My apologies: as Peter correctly says, it should have been Me.TimerInterval.
--

John W. Vinson [MVP]
  #4  
Old April 25th, 2010, 09:42 PM posted to microsoft.public.access
Peter Hibbs
external usenet poster
 
Posts: 871
Default Run code then repeat every 15 minutes

Karren,

One amendment to my previous post, I forgot to insert the End If
command after the DoCmd.Quit statement (but I expect you realised
that).

One other peculiarity I noticed when I tested the code, I initially
used the line that John Vinson used to load the TimerInterval
property, i.e. Me.TimerInterval = 1000 * 60 * 15 but this threw up an
Overflow error at run time which is why I calculated the actual number
of milliseconds and used that. Does anyone know why this is? I am
using A2003 and the code compiles with no problems.

Peter Hibbs.

On Sun, 25 Apr 2010 12:45:23 +0100, Peter Hibbs
wrote:

Karren,

Try this :-

Open the form's property sheet and click on the On Timer event and
then click the ... button (select Code in the pop-up form, if
necessary). In this event add the code below so that it looks
something like this :-

Private Sub Form_Timer()

If Me.Found = "Found" Then
Call FnSafeSendEmail("emailaddress", "mailtitle", "mailbody",
"", "", "")
DoCmd.Quit

End Sub

The Call command should all be on one line, of course.

In your button event you should add this :-

Private Sub Form_Button_Click()
Me.TimerInterval = 900000 '900,000 = 15 mins
End Sub

Note that the first test in the Timer event will not happen until 15
minutes has elapsed, if you want to check the Found field immediately
on clicking the button you can add the code in the Timer event to the
button event. Also, the form should be active all the time the timer
is running, if the form is closed then the timer will stop
(obviously). You could hide it, of course, if you don't need to see it
on screen.

If you need to stop the timer you can reset the TimerInterval property
to 0 but as the database shuts down when the test is True and the
timer expires, I guess you probably don't need this.

HTH

Peter Hibbs.


On Sun, 25 Apr 2010 01:59:01 -0700, Karren Lorr
wrote:

Hello

I am sorry to re-post this question but I can't get it to work after many
hours of trying and searching various websites for assistance.

I am trying to look to see if a text box on my form contains the string
"Found". If it does it will send an e mail (this section works fine). If it
does not then wait for 15 minutes and repeat the check to look for the string.

I can not get the code to wait and repeat.

I tried John Vinson's code
Me.Timer = 1000*60*15
Call Timer ' to have it "do something" the first time

but in this case I get the error "Method or Data Member not found" with the
Me.Time highlighted.

This is what I'm trying to accomplish (the e mail details have taken out for
this post)

Private Sub Form_Button_Click()
If Me.Found = "Found" Then
Call FnSafeSendEmail("emailaddress", "mailtitle", "mailbody", "", "", "")
DoCmd.Quit
Else
'wait 10 minutes and repeat, this is the section I need help with'
End If
End Sub

This small section of code is the last step in a quite complex set of codes.
All the rest of the process works fine and produces the desired results. It
is just this last section I am having problems with, repeating of the form’s
search of this text box.

Can anyone help with this please

 




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 01:50 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.