M
Mike
I am trying to use the FindFirst to make sure I am not about to add a record
to my data table that will cause the program to crash (due to a repeated
primary key)
I can't get FindFirst to work with anything that isn't an object set as
Me.Recordset.Clone
The reason i need to do this is because i am using FindFirst to find a
record in the table that is Me.Recordset later on in the code so I cant just
change the table that is the record source for this form. Here is the code i
have so far
Dim db As Database
Dim rsData As DAO.Recordset
Dim jk As Object
Set db = CurrentDb
Set rsData = db.OpenRecordset("Data")
rsData.FindFirst "[Type] = '" & Me!Type_Select & "' & [Serial #] = '" &
Me!Serial_Number & "'"
If Not rsData.EOF Then
'The above code doesnt work. Error says: Run Time error '3251' Operation is
not supported for this type of object
Then the code does some stuff that works fine. Then:
Set jk = Me.Recordset.Clone
jk.FindFirst "[Type] = '" & Me!Type_Select & "'"
If Not jk.NoMatch Then
This FindFirst works just Fine.
I have tried DIMing something else as an object and then setting that as
rsData.Clone and then using FindFirst on that and i get the same Error.
Sorry that was such a long description. I hope someone has an answer. Thanks!
to my data table that will cause the program to crash (due to a repeated
primary key)
I can't get FindFirst to work with anything that isn't an object set as
Me.Recordset.Clone
The reason i need to do this is because i am using FindFirst to find a
record in the table that is Me.Recordset later on in the code so I cant just
change the table that is the record source for this form. Here is the code i
have so far
Dim db As Database
Dim rsData As DAO.Recordset
Dim jk As Object
Set db = CurrentDb
Set rsData = db.OpenRecordset("Data")
rsData.FindFirst "[Type] = '" & Me!Type_Select & "' & [Serial #] = '" &
Me!Serial_Number & "'"
If Not rsData.EOF Then
'The above code doesnt work. Error says: Run Time error '3251' Operation is
not supported for this type of object
Then the code does some stuff that works fine. Then:
Set jk = Me.Recordset.Clone
jk.FindFirst "[Type] = '" & Me!Type_Select & "'"
If Not jk.NoMatch Then
This FindFirst works just Fine.
I have tried DIMing something else as an object and then setting that as
rsData.Clone and then using FindFirst on that and i get the same Error.
Sorry that was such a long description. I hope someone has an answer. Thanks!