Hope someone can help as driving me bonkers. I am recycling some text which works elsewhere but is throwing an error here. DAO 3.6 Objects Library is referenced. I have put more code in than usual in case anyone spots anything odd
lngSwc is an autonumber and Me.txtSwc is a numeric value where there should always be a match. In my trials its value with mouse hovered over was 7 as expected.
The error message is "Operation is not supported by this type of object"
So far as I can see everything is properly declared as DAO so should be no ambiguity with ADO not liking FindFirst.
Anyone got any bright ideas? If so I would love to hear since I have used this sort of process lots of times without any issue.
Thanks
Code:
Dim stDocName As String
Dim stLinkCriteria As String
Dim intOp As Integer
Dim varCompl As Variant
Dim dbs As DAO.Database
Dim rstAudit As DAO.Recordset
Dim rstSwc As DAO.Recordset
' Set the connection
Set dbs = CurrentDb
Set rstAudit = dbs.OpenRecordset("tblAuditLog")
Set rstSwc = dbs.OpenRecordset("tblSixWeekChecks")
' Identify the operator
intOp = DLookup("lngTsOp", "tblTmpSession")
' Verify that critical text boxes have been completed
If IsNull(Me.cboStaff) Or Me.cboStaff = "" Then
MsgBox "You need to enter the mechanic's name.", vbOKOnly, "Required information"
Me.cboStaff.SetFocus
Exit Sub
End If
If IsNull(Me.txtMileage) Or Me.txtMileage = "" Then
MsgBox "You need to enter the mileage.", vbOKOnly, "Required information"
Me.txtMileage.SetFocus
Exit Sub
End If
' Populate the mechanic textbox
Me.txtMechanic = DLookup("Name", "qcboStaff", "[lngStaff]=" & Me.cboStaff)
' Verify that the SWC data has not already been entered
varCompl = DLookup("lngSwcPlant", "qrySwcCheck")
If varCompl = 0 Then
MsgBox "The results from the Six Week Check have already been entered.", vbOKOnly, "Duplicate data not allowed"
' Add transaction record to tblAuditLog
rstAudit.AddNew
rstAudit!dtmAl = Now()
rstAudit!lngAl = 146
rstAudit!lngAlOp = intOp
rstAudit!lngAlPl = Me.txtPlant
rstAudit.Update
Exit Sub
End If
' Update record in tblSixWeekChecks
rstSwc.FindFirst "[lngSwc] =" & Me.txtSwc
If Not rstSwc.NoMatch Then
rstSwc.Edit
' rstSwc!lngSwcMiles = Me.txtMileage
The error message is "Operation is not supported by this type of object"
So far as I can see everything is properly declared as DAO so should be no ambiguity with ADO not liking FindFirst.
Anyone got any bright ideas? If so I would love to hear since I have used this sort of process lots of times without any issue.
Thanks