S
Scott Whetsell, A.S. - WVSP
I recently passed an update through into my code under the section of Update
Unit Client. The code was somewhat slow before as it is cumbersome, but the
new query take an average of 12-20 sec to run on each execution. Is there
any way to speed it up?
I understand that one of the sections in the first module is blocked out
(not used). I have plans to implement this section as well but it is creating
an undesirable delay in the record updates.
tbl_UnitLog contains:
UL_Unit Text (Special ID - Unit Name)
UL_Date Date (yyyy-mm-dd)
UL_Time Date (hh:nn:ss)
UL_Details Text (Free text)
UL_Status Text (Status code - status description)
UL_User Text (CurrentUser)
UL_UnitID Text (Parsed version of the UL_Unit field pulling the ID
out)
UL_DateTime UL_Date + UL_Time
qry_UnitClient1 Selects the most recent UL_DateTime for each UL_UnitID from
tbl_UnitLog using the MAX operator.
tbl_UnitClient combines data from several tables and serves as a temporary
container for the same till it changes. One record for each unit.
All front ends are run on A2k3 on WinXP or Vista. Max simultaneous users is
4, average is 2. All computers are connected on 10/100 Cat5E lan, some
connected at 100mbps some at 10mbps through an auxillary switch.
Any suggestions are appreciated, Thanks in advance.
==========CODE STARTS HERE==========
Option Compare Database
Option Explicit
Function unitLog(CCNo As Variant, Sts As String, Details As String, SRC As
Variant, _
Optional TimerValue As Variant, Optional NewDate As Date, Optional
NewTime As Date, _
Optional TestIndicator As Variant)
Dim dbs As Database, rst As DAO.Recordset, rst2 As DAO.Recordset, strQry As
String
Dim strSQL As String, rst99 As DAO.Recordset, NEWSTS As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tbl_TMPUnitLogList")
With rst
Do While Not .EOF
Dim UNIT As String
Set rst = dbs.OpenRecordset("tbl_TMPUnitLogLIst")
UNIT = rst(0)
If IsMissing(TestIndicator) Then TestIndicator = "N"
If TestIndicator <> "Y" Then
Set rst = dbs.OpenRecordset("tbl_UnitLog", dbOpenDynaset,
dbAppendOnly)
Else
Set rst = dbs.OpenRecordset("tbl_zzUnitLog", dbOpenDynaset,
dbAppendOnly)
End If
Sts = Trim(ParseText(Sts, 0, " - "))
If Sts = "STA" Then
NEWSTS = DLookup("Org_StationCode", "qry_AssignedUnit",
"[AssignedUnit]='" & UNIT & "'")
Else
NEWSTS = Sts
End If
' Determine if unit safety timers need activated or deactivated
If TestIndicator <> "Y" Then
If Not IsNull(SRC) Then
If Sts = "10-23" Then
strQry = "SELECT qry_UnitLog.UL_CCNo,
Last(qry_UnitLog.UL_STS) AS LastOfUL_STS, Count(qry_UnitLog.UL_Unit) AS
CountOfUL_Unit " & _
"FROM qry_UnitLog GROUP BY qry_UnitLog.UL_CCNo
HAVING (((qry_UnitLog.UL_CCNo)='" & CCNo & "') AND
((Last(qry_UnitLog.UL_STS))=""10-23""))"
Set rst2 = dbs.OpenRecordset(strQry)
If rst2.RecordCount = 0 Then Call
UnitTimer(Trim(ParseText(UNIT, 0, " - ")), Trim(SRC))
ElseIf (Sts = "10-8") Then
Call UnitTimer(Trim(ParseText(UNIT, 0, " - ")), SRC,
"OFF")
ElseIf (Sts = "TIMER") Then
Call UnitTimer(Trim(ParseText(UNIT, 0, " - ")), "UNIT
LOG")
GoTo Exit_unitLog
Else
Dim TimerSts As Variant, UnitID As Variant
UnitID = Trim(ParseText(UNIT, 0, " - "))
TimerSts = DLookup("OM_Expiration",
"tbl_OrganizationMembers", "[OM_UnitID]='" & UnitID & "'")
If (TimerSts <> "") Then
SRC = DLookup("EventCode", "tbl_CCNo", "[CCNo] =
'" & CCNo & "'")
Call UnitTimer(Trim(ParseText(UNIT, 0, " - ")),
Trim(SRC), TimerValue)
End If
End If
End If
End If
' Determine if unit is already on another call and clears if
necessary
'If TestIndicator <> "Y" Then
' Dim OldCCNo As Variant, OldSts As Variant
' OldCCNo = DLookup("UL_CCNo", "qry_UnitStatus", "[Unit] = '" &
Trim(ParseText(UNIT, 0, " - ")) & "'")
' OldSts = DLookup("Status", "qry_UnitStatus", "[Unit] = '" &
Trim(ParseText(UNIT, 0, " - ")) & "'")
' If Not IsNull(OldCCNo) Then
' If OldSts <> "10-8" Then
' If CCNo <> OldCCNo Then
' With rst
' rst.AddNew
' rst![UL_CCNo] = OldCCNo
' rst![UL_Unit] = UCase(UNIT)
' rst![UL_User] = UCase(Left(CurrentUser(), 3))
' rst![UL_STS] = "10-8"
' rst![UL_Details] = "UNIT REROUTED TO INC# " &
CCNo
' If (NewDate = "00:00:00") Then rst![UL_Date] =
Format(Date, "yyyy-mm-dd") Else rst![UL_Date] = NewDate
' If (NewTime = "00:00:00") Then rst![UL_Time] =
Format(Time(), "hh:nn:ss") Else rst![UL_Time] = NewTime
' rst.Update
' End With
' End If
' End If
' End If
'End If
' Add new unit activity to log
If (NewDate="00:00:00") Then NewDate = Format(Now(), "yyyy-mm-dd")
If (NewTime="00:00:00") Then NewTime = Format(Now(), "hh:nn:ss")
With rst
rst.AddNew
rst![UL_CCNo] = CCNo
rst![UL_Unit] = UCase(UNIT)
rst![UL_User] = UCase(Left(CurrentUser(), 3))
rst![UL_STS] = UCase(NEWSTS)
rst![UL_Details] = UCase(Trim(Details))
rst![UL_Date] = NewDate
rst![UL_Time] = NewTime
rst![UL_UnitID] = Trim(ParseText(UNIT, 0, " - "))
rst![UL_DateTime] = NewDate + NewTime
rst.Update
End With
' Update Unit Record to reflect current CCNo
If UCase(Sts) = "10-8" Then
strSQL = "UPDATE tbl_OrganizationMembers SET OM_CCNo = '' " & _
"WHERE OM_UnitID = '" & Trim(ParseText(UNIT, 0, " - "))
& "'"
Else
strSQL = "UPDATE tbl_OrganizationMembers SET OM_CCNo = '" & CCNo
& "' " & _
"WHERE OM_UnitID = '" & Trim(ParseText(UNIT, 0, " - "))
& "'"
End If
CurrentDb.Execute strSQL, dbFailOnError
' Alpha Patrol Status
If TestIndicator <> "Y" Then
If Sts = "10-41A" Then
strSQL = "UPDATE tbl_OrganizationMembers SET OM_Alpha = '*'"
& _
"WHERE OM_UnitID = '" & Trim(ParseText(UNIT, 0, " - "))
& "'"
CurrentDb.Execute strSQL, dbFailOnError
ElseIf Sts = "10-42A" Then
strSQL = "UPDATE tbl_OrganizationMembers SET OM_Alpha = ''"
& _
"WHERE OM_UnitID = '" & Trim(ParseText(UNIT, 0, " - "))
& "'"
CurrentDb.Execute strSQL, dbFailOnError
ElseIf ((Sts = "10-41") Or (Sts = "10-42")) Then
Dim AlphaSts As Variant
AlphaSts = DLookup("OM_Alpha", "tbl_OrganizationMembers",
"[OM_UnitID]='" & _
Trim(ParseText(UNIT, 0, " - ")) & "'")
If (AlphaSts = "*") Then
Dim rslt As Variant
rslt = MsgBox("" & UNIT & " is currently listed on Alpha
Patrol." & _
Chr(10) & Chr(13) & Chr(10) & Chr(13) & "Clear unit from
Alpha Patrol?", _
vbYesNo, "Unit on Alpha Patrol")
If rslt = 6 Then
strSQL = "UPDATE tbl_OrganizationMembers SET
OM_Alpha = ''" & _
"WHERE OM_UnitID = '" & Trim(ParseText(UNIT, 0,
" - ")) & "'"
CurrentDb.Execute strSQL, dbFailOnError
End If
End If
End If
End If
' Clear joined units when going off duty
If Sts = "10-42" Or Sts = "10-42A" Then
On Error Resume Next
Set rst = dbs.OpenRecordset("tbl_UnitsTogether")
strSQL = "DELETE * FROM tbl_UnitsTogether WHERE Unit1 = '" &
ParseText(UNIT, 0, " - ") & "'"
CurrentDb.Execute strSQL
strSQL = "DELETE * FROM tbl_UnitsTogether WHERE Unit2 = '" &
ParseText(UNIT, 0, " - ") & "'"
CurrentDb.Execute strSQL
End If
' Clear unit from pending unit list
strSQL = "DELETE * FROM tbl_TMPUnitLogList WHERE UnitID = '" & UNIT
& "'"
CurrentDb.Execute strSQL, dbFailOnError
.MoveNext
Loop
End With
' Update UnitClient
DoCmd.SetWarnings (0)
strSQL = "DELETE * FROM tbl_UnitClient"
CurrentDb.Execute strSQL, dbFailOnError
strSQL = "INSERT INTO tbl_UnitClient ( UnitID, [DateTime], Status,
ULRCN, CCNo, " & _
"AlphaPatrol, PatrolZone, PCO, TimerExpr ) SELECT
qry_UnitClient1.UL_UnitID, " & _
"qry_UnitClient1.DateTime, tbl_UnitLog.UL_STS, tbl_UnitLog.UL_RCN, "
& _
"tbl_UnitLog.UL_CCNo, tbl_OrganizationMembers.OM_Alpha,
tbl_Organizations." & _
"Org_SectionNumber, tbl_UnitLog.UL_User,
tbl_OrganizationMembers.OM_Expiration " & _
"FROM ((qry_UnitClient1 INNER JOIN tbl_UnitLog ON
(qry_UnitClient1.DateTime = " & _
"tbl_UnitLog.UL_DateTime) AND (qry_UnitClient1.UL_UnitID =
tbl_UnitLog.UL_UnitID)) " & _
"INNER JOIN tbl_OrganizationMembers ON tbl_UnitLog.UL_UnitID = " & _
"tbl_OrganizationMembers.OM_UnitID) INNER JOIN tbl_Organizations ON
" & _
"tbl_OrganizationMembers.OM_Org = tbl_Organizations.Org_Name " & _
"WHERE
(((qry_UnitClient1.UL_UnitID)<>DLookUp(""[CallSign]"",""[Settings]"")) AND "
& _
"((tbl_UnitLog.UL_STS) Not Like (""10-42*""))) " & _
"ORDER BY qry_UnitClient1.UL_UnitID"
CurrentDb.Execute strSQL, dbFailOnError
DoCmd.SetWarnings (-1)
Exit_unitLog:
strSQL = "UPDATE Settings SET UnitLogLastUpdate = #" & Format(Now(),
"yyyy-mm-dd hh:nn:ss") & "#"
CurrentDb.Execute strSQL, dbFailOnError
Set CCNo = Nothing
Set dbs = Nothing
Set rst = Nothing
Set rst2 = Nothing
Set rst99 = Nothing
End Function
Public Function UnitTimer(UnitID As String, SRC As Variant, Optional
TimerValue As Variant)
Dim strSQL As String
If (SRC = "UNIT LOG") And (IsMissing(TimerValue)) Then
1
TimerValue = InputBox("ENTER TIMER DURATION IN MINUTES OR 'OFF' TO TURN
TIMER OFF", "TIMER DURATION")
End If
If IsMissing(TimerValue) Then
TimerValue = DLookup("EventTimer", "tbl_EventCodes", "[EventCode]='" &
SRC & "'")
End If
If (IsNumeric(TimerValue) = False) And (UCase(Trim(TimerValue)) <> "OFF") Then
MsgBox "INVALID TIMER VALUE ENTERED, PLEASE TRY AGAIN", vbOKOnly, "ERROR"
GoTo 1
ElseIf IsNumeric(TimerValue) Then
TimerValue = Now + (TimerValue * 6.94444444444444E-04)
strSQL = "UPDATE tbl_OrganizationMembers SET OM_Expiration = '" &
TimerValue & "'" & _
"WHERE OM_UnitID = '" & Trim(ParseText(UnitID, 0, " - ")) & "'"
CurrentDb.Execute strSQL, dbFailOnError
ElseIf TimerValue = "OFF" Then
strSQL = "UPDATE tbl_OrganizationMembers SET OM_Expiration = Null " & _
"WHERE OM_UnitID = '" & Trim(ParseText(UnitID, 0, " - ")) & "'"
CurrentDb.Execute strSQL, dbFailOnError
End If
End Function
Unit Client. The code was somewhat slow before as it is cumbersome, but the
new query take an average of 12-20 sec to run on each execution. Is there
any way to speed it up?
I understand that one of the sections in the first module is blocked out
(not used). I have plans to implement this section as well but it is creating
an undesirable delay in the record updates.
tbl_UnitLog contains:
UL_Unit Text (Special ID - Unit Name)
UL_Date Date (yyyy-mm-dd)
UL_Time Date (hh:nn:ss)
UL_Details Text (Free text)
UL_Status Text (Status code - status description)
UL_User Text (CurrentUser)
UL_UnitID Text (Parsed version of the UL_Unit field pulling the ID
out)
UL_DateTime UL_Date + UL_Time
qry_UnitClient1 Selects the most recent UL_DateTime for each UL_UnitID from
tbl_UnitLog using the MAX operator.
tbl_UnitClient combines data from several tables and serves as a temporary
container for the same till it changes. One record for each unit.
All front ends are run on A2k3 on WinXP or Vista. Max simultaneous users is
4, average is 2. All computers are connected on 10/100 Cat5E lan, some
connected at 100mbps some at 10mbps through an auxillary switch.
Any suggestions are appreciated, Thanks in advance.
==========CODE STARTS HERE==========
Option Compare Database
Option Explicit
Function unitLog(CCNo As Variant, Sts As String, Details As String, SRC As
Variant, _
Optional TimerValue As Variant, Optional NewDate As Date, Optional
NewTime As Date, _
Optional TestIndicator As Variant)
Dim dbs As Database, rst As DAO.Recordset, rst2 As DAO.Recordset, strQry As
String
Dim strSQL As String, rst99 As DAO.Recordset, NEWSTS As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tbl_TMPUnitLogList")
With rst
Do While Not .EOF
Dim UNIT As String
Set rst = dbs.OpenRecordset("tbl_TMPUnitLogLIst")
UNIT = rst(0)
If IsMissing(TestIndicator) Then TestIndicator = "N"
If TestIndicator <> "Y" Then
Set rst = dbs.OpenRecordset("tbl_UnitLog", dbOpenDynaset,
dbAppendOnly)
Else
Set rst = dbs.OpenRecordset("tbl_zzUnitLog", dbOpenDynaset,
dbAppendOnly)
End If
Sts = Trim(ParseText(Sts, 0, " - "))
If Sts = "STA" Then
NEWSTS = DLookup("Org_StationCode", "qry_AssignedUnit",
"[AssignedUnit]='" & UNIT & "'")
Else
NEWSTS = Sts
End If
' Determine if unit safety timers need activated or deactivated
If TestIndicator <> "Y" Then
If Not IsNull(SRC) Then
If Sts = "10-23" Then
strQry = "SELECT qry_UnitLog.UL_CCNo,
Last(qry_UnitLog.UL_STS) AS LastOfUL_STS, Count(qry_UnitLog.UL_Unit) AS
CountOfUL_Unit " & _
"FROM qry_UnitLog GROUP BY qry_UnitLog.UL_CCNo
HAVING (((qry_UnitLog.UL_CCNo)='" & CCNo & "') AND
((Last(qry_UnitLog.UL_STS))=""10-23""))"
Set rst2 = dbs.OpenRecordset(strQry)
If rst2.RecordCount = 0 Then Call
UnitTimer(Trim(ParseText(UNIT, 0, " - ")), Trim(SRC))
ElseIf (Sts = "10-8") Then
Call UnitTimer(Trim(ParseText(UNIT, 0, " - ")), SRC,
"OFF")
ElseIf (Sts = "TIMER") Then
Call UnitTimer(Trim(ParseText(UNIT, 0, " - ")), "UNIT
LOG")
GoTo Exit_unitLog
Else
Dim TimerSts As Variant, UnitID As Variant
UnitID = Trim(ParseText(UNIT, 0, " - "))
TimerSts = DLookup("OM_Expiration",
"tbl_OrganizationMembers", "[OM_UnitID]='" & UnitID & "'")
If (TimerSts <> "") Then
SRC = DLookup("EventCode", "tbl_CCNo", "[CCNo] =
'" & CCNo & "'")
Call UnitTimer(Trim(ParseText(UNIT, 0, " - ")),
Trim(SRC), TimerValue)
End If
End If
End If
End If
' Determine if unit is already on another call and clears if
necessary
'If TestIndicator <> "Y" Then
' Dim OldCCNo As Variant, OldSts As Variant
' OldCCNo = DLookup("UL_CCNo", "qry_UnitStatus", "[Unit] = '" &
Trim(ParseText(UNIT, 0, " - ")) & "'")
' OldSts = DLookup("Status", "qry_UnitStatus", "[Unit] = '" &
Trim(ParseText(UNIT, 0, " - ")) & "'")
' If Not IsNull(OldCCNo) Then
' If OldSts <> "10-8" Then
' If CCNo <> OldCCNo Then
' With rst
' rst.AddNew
' rst![UL_CCNo] = OldCCNo
' rst![UL_Unit] = UCase(UNIT)
' rst![UL_User] = UCase(Left(CurrentUser(), 3))
' rst![UL_STS] = "10-8"
' rst![UL_Details] = "UNIT REROUTED TO INC# " &
CCNo
' If (NewDate = "00:00:00") Then rst![UL_Date] =
Format(Date, "yyyy-mm-dd") Else rst![UL_Date] = NewDate
' If (NewTime = "00:00:00") Then rst![UL_Time] =
Format(Time(), "hh:nn:ss") Else rst![UL_Time] = NewTime
' rst.Update
' End With
' End If
' End If
' End If
'End If
' Add new unit activity to log
If (NewDate="00:00:00") Then NewDate = Format(Now(), "yyyy-mm-dd")
If (NewTime="00:00:00") Then NewTime = Format(Now(), "hh:nn:ss")
With rst
rst.AddNew
rst![UL_CCNo] = CCNo
rst![UL_Unit] = UCase(UNIT)
rst![UL_User] = UCase(Left(CurrentUser(), 3))
rst![UL_STS] = UCase(NEWSTS)
rst![UL_Details] = UCase(Trim(Details))
rst![UL_Date] = NewDate
rst![UL_Time] = NewTime
rst![UL_UnitID] = Trim(ParseText(UNIT, 0, " - "))
rst![UL_DateTime] = NewDate + NewTime
rst.Update
End With
' Update Unit Record to reflect current CCNo
If UCase(Sts) = "10-8" Then
strSQL = "UPDATE tbl_OrganizationMembers SET OM_CCNo = '' " & _
"WHERE OM_UnitID = '" & Trim(ParseText(UNIT, 0, " - "))
& "'"
Else
strSQL = "UPDATE tbl_OrganizationMembers SET OM_CCNo = '" & CCNo
& "' " & _
"WHERE OM_UnitID = '" & Trim(ParseText(UNIT, 0, " - "))
& "'"
End If
CurrentDb.Execute strSQL, dbFailOnError
' Alpha Patrol Status
If TestIndicator <> "Y" Then
If Sts = "10-41A" Then
strSQL = "UPDATE tbl_OrganizationMembers SET OM_Alpha = '*'"
& _
"WHERE OM_UnitID = '" & Trim(ParseText(UNIT, 0, " - "))
& "'"
CurrentDb.Execute strSQL, dbFailOnError
ElseIf Sts = "10-42A" Then
strSQL = "UPDATE tbl_OrganizationMembers SET OM_Alpha = ''"
& _
"WHERE OM_UnitID = '" & Trim(ParseText(UNIT, 0, " - "))
& "'"
CurrentDb.Execute strSQL, dbFailOnError
ElseIf ((Sts = "10-41") Or (Sts = "10-42")) Then
Dim AlphaSts As Variant
AlphaSts = DLookup("OM_Alpha", "tbl_OrganizationMembers",
"[OM_UnitID]='" & _
Trim(ParseText(UNIT, 0, " - ")) & "'")
If (AlphaSts = "*") Then
Dim rslt As Variant
rslt = MsgBox("" & UNIT & " is currently listed on Alpha
Patrol." & _
Chr(10) & Chr(13) & Chr(10) & Chr(13) & "Clear unit from
Alpha Patrol?", _
vbYesNo, "Unit on Alpha Patrol")
If rslt = 6 Then
strSQL = "UPDATE tbl_OrganizationMembers SET
OM_Alpha = ''" & _
"WHERE OM_UnitID = '" & Trim(ParseText(UNIT, 0,
" - ")) & "'"
CurrentDb.Execute strSQL, dbFailOnError
End If
End If
End If
End If
' Clear joined units when going off duty
If Sts = "10-42" Or Sts = "10-42A" Then
On Error Resume Next
Set rst = dbs.OpenRecordset("tbl_UnitsTogether")
strSQL = "DELETE * FROM tbl_UnitsTogether WHERE Unit1 = '" &
ParseText(UNIT, 0, " - ") & "'"
CurrentDb.Execute strSQL
strSQL = "DELETE * FROM tbl_UnitsTogether WHERE Unit2 = '" &
ParseText(UNIT, 0, " - ") & "'"
CurrentDb.Execute strSQL
End If
' Clear unit from pending unit list
strSQL = "DELETE * FROM tbl_TMPUnitLogList WHERE UnitID = '" & UNIT
& "'"
CurrentDb.Execute strSQL, dbFailOnError
.MoveNext
Loop
End With
' Update UnitClient
DoCmd.SetWarnings (0)
strSQL = "DELETE * FROM tbl_UnitClient"
CurrentDb.Execute strSQL, dbFailOnError
strSQL = "INSERT INTO tbl_UnitClient ( UnitID, [DateTime], Status,
ULRCN, CCNo, " & _
"AlphaPatrol, PatrolZone, PCO, TimerExpr ) SELECT
qry_UnitClient1.UL_UnitID, " & _
"qry_UnitClient1.DateTime, tbl_UnitLog.UL_STS, tbl_UnitLog.UL_RCN, "
& _
"tbl_UnitLog.UL_CCNo, tbl_OrganizationMembers.OM_Alpha,
tbl_Organizations." & _
"Org_SectionNumber, tbl_UnitLog.UL_User,
tbl_OrganizationMembers.OM_Expiration " & _
"FROM ((qry_UnitClient1 INNER JOIN tbl_UnitLog ON
(qry_UnitClient1.DateTime = " & _
"tbl_UnitLog.UL_DateTime) AND (qry_UnitClient1.UL_UnitID =
tbl_UnitLog.UL_UnitID)) " & _
"INNER JOIN tbl_OrganizationMembers ON tbl_UnitLog.UL_UnitID = " & _
"tbl_OrganizationMembers.OM_UnitID) INNER JOIN tbl_Organizations ON
" & _
"tbl_OrganizationMembers.OM_Org = tbl_Organizations.Org_Name " & _
"WHERE
(((qry_UnitClient1.UL_UnitID)<>DLookUp(""[CallSign]"",""[Settings]"")) AND "
& _
"((tbl_UnitLog.UL_STS) Not Like (""10-42*""))) " & _
"ORDER BY qry_UnitClient1.UL_UnitID"
CurrentDb.Execute strSQL, dbFailOnError
DoCmd.SetWarnings (-1)
Exit_unitLog:
strSQL = "UPDATE Settings SET UnitLogLastUpdate = #" & Format(Now(),
"yyyy-mm-dd hh:nn:ss") & "#"
CurrentDb.Execute strSQL, dbFailOnError
Set CCNo = Nothing
Set dbs = Nothing
Set rst = Nothing
Set rst2 = Nothing
Set rst99 = Nothing
End Function
Public Function UnitTimer(UnitID As String, SRC As Variant, Optional
TimerValue As Variant)
Dim strSQL As String
If (SRC = "UNIT LOG") And (IsMissing(TimerValue)) Then
1
TimerValue = InputBox("ENTER TIMER DURATION IN MINUTES OR 'OFF' TO TURN
TIMER OFF", "TIMER DURATION")
End If
If IsMissing(TimerValue) Then
TimerValue = DLookup("EventTimer", "tbl_EventCodes", "[EventCode]='" &
SRC & "'")
End If
If (IsNumeric(TimerValue) = False) And (UCase(Trim(TimerValue)) <> "OFF") Then
MsgBox "INVALID TIMER VALUE ENTERED, PLEASE TRY AGAIN", vbOKOnly, "ERROR"
GoTo 1
ElseIf IsNumeric(TimerValue) Then
TimerValue = Now + (TimerValue * 6.94444444444444E-04)
strSQL = "UPDATE tbl_OrganizationMembers SET OM_Expiration = '" &
TimerValue & "'" & _
"WHERE OM_UnitID = '" & Trim(ParseText(UnitID, 0, " - ")) & "'"
CurrentDb.Execute strSQL, dbFailOnError
ElseIf TimerValue = "OFF" Then
strSQL = "UPDATE tbl_OrganizationMembers SET OM_Expiration = Null " & _
"WHERE OM_UnitID = '" & Trim(ParseText(UnitID, 0, " - ")) & "'"
CurrentDb.Execute strSQL, dbFailOnError
End If
End Function