Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto start macro

Status
Not open for further replies.

timotai

Technical User
Apr 13, 2002
119
GB
Hi

i have a code that pings a user through net send but I need this to happen at a specific point during the day. at 16:00.

The coding is below:

Function ping()
Dim netmessage1

Dim recipient1
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim StrSql As String

StrSql = "SELECT WeekLog.[Employee Number]as emp,
Shift_Patterns.ShiftLevel, Shift_Patterns.Moday FROM
Shift_Patterns INNER JOIN WeekLog ON (WeekLog.ShiftLevel =
Shift_Patterns.ShiftLevel) AND (Shift_Patterns.
[ShiftPattern ID] = WeekLog.[ShiftPattern ID]) AND
(Shift_Patterns.[ShiftPattern ID] = WeekLog.[ShiftPattern
ID])WHERE (((Shift_Patterns.Moday)='10:00-6:00'));"

Set db = CurrentDb
Set rst = db.OpenRecordset(StrSql, dbOpenSnapshot)

If rst.BOF And rst.EOF Then
Call MsgBox("No Team Members meet the criteria.")
Else
Do Until rst.EOF
netmessage1 = "The TeamMember on the 8:00-4:00 Shift has
now left please now take over the Odin support Mail basket"

Shell ("net send " & rst("emp") & " " & netmessage1 & "")
rst.MoveNext
Loop
End If

rst.close
Set rst = Nothing
db.close
Set db = Nothing

netmessage1 = "The TeamMember on the 8:00-4:00 Shift has
now left please now take over the Odin support Mail basket"

Shell ("net send " & recipient1 & " " & netmessage1 & "")

End Function


So What can I include in this to make it execute at a
certain time.

I have been experimenting with loops and time() = 16:00 but
cannot get it to work

Many Thanks

tim
 
Execute the code from an autoexec macro and set it up to run on the windows scheduler at your desired time.

Just one way...

Im sure there are others...



lonniejohnson@prodev.com
ProDev, MS Access Applications B-) ,
May God blow your mind with His Glory in 2003.
 
Hi Tim!

There are other ways of doing this but Lonnie's is probably simplest. The thing I wanted to mention was, for this code to run via the macro, it must be in a module and have the keyword Public before the word Function.

hth
Jeff Bridgham
bridgham@purdue.edu
 
sounds like a good idea unfortunatly not feasable for the set of my database as it is to be used by many users and various PC's so I don't want to set a scheduler on each one. Is there another way?

Many thanks for the suggestions, I appreciate anyone taking the time to help me out

Many Thanks

Tim
 
Hello,

Have a form that opens on start up and then hides it self.
In the ontimer event of the form have some code like this:-

Dim time As Date
Dim strCurrentTime
time = Now()
strCurrentTime = Right(time, 8)
strCurrentTime = Left(strCurrentTime, 5)

If strCurrentTime = "16:00" Then
'Your code Here'

End If

And then set the timer value to run the code every 60 seconds 60000 (or 59999 may be better!)

Works for me! HTH.

Steve C. Make things as simple as possible — but no simpler.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top