D
Don Starnes
I am writing a function that tests if a record has been created in a table;
it is used before creating a record:
Dim cvdb As Database
Dim cvjoinrst As DAO.Recordset
Dim cvjoinspec As String
Dim mytest As Integer
' specify the database
Set cvdb = currentdb()
' open the join table
Set cvjoinrst = cvdb.OpenRecordset("joins_group_person")
cvjoinspec = "[index_groups]=2 AND [index_persons]=8"
With cvjoinrst
cvBookmark = .Bookmark ' Store current record location.
.FindFirst cvjoinspec ' look for the join
If .NoMatch Then ' If there is no such join,
mytest = 0 ' set the value to 0.
Else ' If there is a join,
mytest = 1 ' set the value to 1
End If
.Bookmark = cvBookmark ' go to the last current record.
End With
This code gives an error: Operation not supported for this type of object
What am I doing wrong?
Thanks in advance for your generous help,
Don
it is used before creating a record:
Dim cvdb As Database
Dim cvjoinrst As DAO.Recordset
Dim cvjoinspec As String
Dim mytest As Integer
' specify the database
Set cvdb = currentdb()
' open the join table
Set cvjoinrst = cvdb.OpenRecordset("joins_group_person")
cvjoinspec = "[index_groups]=2 AND [index_persons]=8"
With cvjoinrst
cvBookmark = .Bookmark ' Store current record location.
.FindFirst cvjoinspec ' look for the join
If .NoMatch Then ' If there is no such join,
mytest = 0 ' set the value to 0.
Else ' If there is a join,
mytest = 1 ' set the value to 1
End If
.Bookmark = cvBookmark ' go to the last current record.
End With
This code gives an error: Operation not supported for this type of object
What am I doing wrong?
Thanks in advance for your generous help,
Don