Run Code via Shedule Task Q

S

Sean

I have the following code that executes when I click a particular
button within a database, what I am trying to do is schedule this code
so that it will run within Schedule Tasks, say every 10 mins, on its
own. How would I do this?

Thanks


Private Sub LoadClockDataButton_Click()

Dim objClockP As ClockFileParser
Dim objClockC As ClockControler
Dim strFilename As String

Dim lngNumRecordsRead As Long
Dim intRetStatus As Integer

Dim strErrString As String

Dim dbs As Database
Dim rst As Recordset
Dim qdf As QueryDef
Dim strQry As String

'Get Store Details
Set dbs = CurrentDb
strQry = "select * from StoreDetails"
Set rst = dbs.OpenRecordset(strQry, dbOpenSnapshot)

If rst.EOF And rst.BOF Then
Debug.Print MsgBox("Panic! No Store Details Record!", vbOKOnly,
"Error!")
Exit Sub
End If

rst.MoveFirst

DoCmd.OpenForm ("LoadProgressForm")

Forms!LoadProgressForm!OpCodeBar.Value = "Communicating With
Clocks..."

Set objClockC = New ClockControler

If Form_MainSwitchboardForm.ClockType = "H" Then

'This for "Hand" clocks...
intRetStatus = objClockC.FireHand()

Else

intRetStatus = objClockC.FireSynman()

End If

strErrString = ""

Select Case inreetstatus

Case 0:

Debug.Print "All OK with collection..."

Case 1:

strErrString = "Couldnt Start Clock Collection Process!"

Case 2:

strErrString = "Clock Collection Process Timed Out!"

End Select

If strErrString <> "" Then

intRunRes = MsgBox(strErrString, vbOKOnly, "Error Collecting
Clocks!")
Exit Sub

End If

If Form_MainSwitchboardForm.ClockType = "H" Then

strFilename = Forms!MainSwitchboardForm!clockdefinepath + "\" +
rst.Fields("ClockDataFilename")

Set objClockP = New ClockFileParser

objClockP.DataFileName = strFilename

Forms!LoadProgressForm!OpCodeBar.Value = "Loading Clocks..."

lngNumRecordsRead = objClockP.DoClockParserHand32()

Else

strFilename = Forms!MainSwitchboardForm!clockdefinepath + "\" +
rst.Fields("ClockDataFilename")

Set objClockP = New ClockFileParser

objClockP.DataFileName = strFilename

Forms!LoadProgressForm!OpCodeBar.Value = "Loading Clocks..."

lngNumRecordsRead = objClockP.DoClockParser()

End If

rst.Close

'if DoClockParser fails, stop everything and go home....

If lngNumRecordsRead = -1 Then

Forms!LoadProgressForm!CloseButton.Enabled = True

Exit Sub

End If


Forms!LoadProgressForm!OpCodeBar.Value = "Checking Clocks..."
Forms!LoadProgressForm!PerCentComplete.Value = (0)
Forms!LoadProgressForm.Repaint

intRetStatus = objClockP.ClockFileChecks()

'Swipe&Go - call method to 1. set up the LADate for each RawClockFile
record
' 2. sort out the A100 S&G clockings into
genuine Clock Codes e.g B200, C120 etc
If Form_MainSwitchboardForm.chkSwipeGo = True Then

intRetStatus = objClockP.SwipeGoProcessRCF()

End If

Forms!LoadProgressForm!OpCodeBar.Value = "Loading Daily Attendance..."
Forms!LoadProgressForm!PerCentComplete.Value = (0)
Forms!LoadProgressForm.Repaint

intRetStatus = objClockP.LoadIntoDailyAttendance()

Forms!LoadProgressForm!CloseButton.Enabled = True

Forms!LoadProgressForm!OpCodeBar.Value = "Finished Loading..."

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top