Dumferling
Member
- Local time
- Today, 21:32
- Joined
- Apr 28, 2020
- Messages
- 102
I am trying to get the database to check if a record exists. I am using Seek to do this where the code will pick up the record number from the primary table and search on the related table for that index number (IDContract).
The code is:
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim vblIndex As Integer
vblIndex = Forms!frmCContractBrowser!ID
'On Error GoTo ErrorHandler
Set db = CurrentDb()
Set rst = db.OpenRecordset("tblCPOPIA", dbOpenDynaset)
' The index name for Employee ID.
rst.Index = "IDContract"
rst.Seek "=", vblIndex
If rst.NoMatch Then
Dim msg As String
msg = MsgBox("Record not found", vbOKOnly, "LMD Notification")
Else
End If
rst.Close
db.Close
Set rst = Nothing
Set db = Nothing
I am getting an error on the rstIndex = "IDContract" line - Operation is not supported for this kind of object.
I cannot see what I am doing wrong. It is something simple, I am sure but looking at examples, I can't see it.
The code is:
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim vblIndex As Integer
vblIndex = Forms!frmCContractBrowser!ID
'On Error GoTo ErrorHandler
Set db = CurrentDb()
Set rst = db.OpenRecordset("tblCPOPIA", dbOpenDynaset)
' The index name for Employee ID.
rst.Index = "IDContract"
rst.Seek "=", vblIndex
If rst.NoMatch Then
Dim msg As String
msg = MsgBox("Record not found", vbOKOnly, "LMD Notification")
Else
End If
rst.Close
db.Close
Set rst = Nothing
Set db = Nothing
I am getting an error on the rstIndex = "IDContract" line - Operation is not supported for this kind of object.
I cannot see what I am doing wrong. It is something simple, I am sure but looking at examples, I can't see it.