Private Sub Form_Current()
On Error GoTo Callform_current_error
Dim tim As Variant
Dim lab As Currency
Dim serial As Variant
Dim instdate As Date
Dim expiredate As Variant
Dim TestDate As Date
Dim equip As String
Dim cust As String
Dim callno As Long
Dim FullPath As String
Dim strDocName As String
Dim StrRst As Recordset
Dim StrDb As Database
Dim StrSql As String
StrSql = "SELECT * FROM Equipment WHERE equip_index = " & Me.call_equip_sno
Set StrDb = CurrentDb()
Set StrRst = StrDb.OpenRecordset(StrSql)
expiredate = StrRst("[equip_expire_date]")
serial = StrRst("[equip_serialno]")
equip = StrRst("[equip_name1]")
callno = Me.call_no
cust = DLookup("[product_customer]", "Product", "[product_name] = '" & equip & "'")
'Debug.Print equip, callno, cust
If cust = "Andrews" Then cust = "BAXI GROUP COMPANIES"
strDocName = "*" & callno & ".doc"
FullPath = "Z:\Data\CUSTOMERS\" & cust & "\Site Visits\" & strDocName
'Debug.Print FullPath
'Check folder contains a doc, open info window if not, doc if it does
If Dir([FullPath]) <> Empty Then
Me.btndoc.Caption = "Report"
Else
Me.btndoc.Caption = "No Report"
End If
If IsNull(expiredate) Then
If IsNull(serial) Then
expiredate = #1/1/1992# ' One year after Company started.
Else
serial = Left(serial, 2) + 1
expiredate = CDate("01/01/" & serial)
End If
End If
TestDate = Format(Now(), "Short Date")
If (TestDate - expiredate) > 0 Then
Me![call_cost].Visible = True ' outof warranty
Me![call_price].Visible = True
Me![labour].Visible = True
Me![warranty].Visible = False
Else
Me![warranty].Visible = True ' in warranty
End If
If IsNull(call_finishtime) Or expiredate - TestDate > 0 Then 'in warranty no labour
' no labour calc needed.
lab = 0
Else
tim = DateDiff("n", [call_startime], [call_finishtime])
If tim < 60 Then
lab = firsthour ' Callout and first hour £40.00 set on form open
Else
lab = firsthour + (secondhour * (tim - 60) / 60) ' Hourly rate after first hour, £30.00
End If
End If
Me.labour = lab
Exit_Form_Current:
Exit Sub
Callform_current_error:
MsgBox Err.Description
Resume Exit_Form_Current
End Sub