Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 16th, 2009, 07:18 AM
Registered User
 
Join Date: Sep 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default Command button with timer

Hi;

I have n button that executes the application obviously, but what I want to do is set a timer so that the timer
execute the application every 15 minutes. I’ve tried with this code but theLabel1 counts to 15 and then a error variable not defined pops up the Interval is set to a 1000 if I take the code out then the application is fine again i dont know what i am missing.

Option Explicit
Dim MinCount As Integer

Sub tmrMinute_Timer()
MinCount = MinCount + 1
Label1.Caption = MinCount
If (MinCount = 15) Then
Call cmdstart_Click
MinCount = 0
End If
End Sub
 
Old October 16th, 2009, 09:22 PM
Authorized User
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Okay, timer1 is set to an interval of 1000 which is one second. So your code is executing every 15 seconds. If you want to have this run every 15 minutes then you need to set the interval to 60000.



Good Luck
 
Old October 19th, 2009, 02:09 AM
Registered User
 
Join Date: Sep 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi thanks for that it runs and then after 15 minutes it execute the cndstart button but then it throws out a variable not defined error “oleasMailItem” but if I take the timer out and click the cmdstart button then the application runs fine with out errors.

Code:
Option Explicit
Dim MinCount As Integer

Private Sub cmdstart_Click()

If lblMsgA <= 1000 Then
Dim oleasApp As Outlook.Application
   Set oleasApp = CreateObject("Outlook.Application")

Dim oleasNs As Outlook.Namespace
   Set oleasNs = oleasApp.GetNamespace("MAPI")
   oleasNs.Logon

Dim oleasMail As Outlook.MailItem
   Set oleasMail = oleasApp.CreateItem(oleasMailItem)
oleasMail.To = [email protected]
oleasMail.Subject = "VB TEST"
   oleasMail.Body = _
        "Good Day Eason" & ", " & vbCr & vbCr & vbTab & _
        "Please note that your credit is all most finish ." & ", " & vbCr & vbCr & vbTab & _
        "Many Thanks"
   oleasMail.Send

MsgBox "All done...", vbMsgBoxSetForeground
   oleasNs.Logoff
   Set oleasNs = Nothing
   Set oleasMail = Nothing
   Set oleasApp = Nothing
End If
End Sub

Sub tmr_Minute_Timer()
MinCount = MinCount + 1
Label1.Caption = MinCount
If (MinCount = 15) Then
Call cmdstart_Click
MinCount = 0
End If
End Sub
 
Old October 19th, 2009, 10:52 AM
Authorized User
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Don't know why but from what you have posted, the variable is not defined anywhere...



Good Luck
 
Old October 20th, 2009, 02:25 AM
Registered User
 
Join Date: Sep 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks for the effort I got it sorted I did not have my MAPI reference in place.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Command Button VB Code taraj Access 16 May 22nd, 2008 10:37 AM
'Hidden' Command Button David Mulvey Word VBA 0 January 9th, 2007 11:21 PM
Command Button Question eoghang Excel VBA 2 September 25th, 2006 08:33 PM
navigate b/w worksheets with command button sriramus Access VBA 1 March 26th, 2006 06:40 AM
command button qry mohiddin52 Access 0 December 22nd, 2003 08:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.