Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FindFirst Error - Operation is not supported for this type of object 3

Status
Not open for further replies.

BenjaminLim

IS-IT--Management
May 24, 2000
73
GB
I encountered the above run-time error : 3251 with the following codes.

Please advice what I have done wrongly & how to correct the codes. The linw is at specifically :

rst1.FindFirst "rst1!Date1 = rstd1!Date1"


Code Listing
==================

Sub Forecast()
Dim SeqA As String, SeqB As String, NumA As String, NumB As String
Dim DateA As Date, DateB As Date, OrigA As String, OrigB As String
Dim PriceA As Integer, PriceB As Integer
Dim db As Database, rstd1 As Recordset, rstd2 As Recordset, rstd3 As Recordset
Dim rst As Recordset, rst1 As Recordset, rst2 As Recordset, rst3 As Recordset
Dim varBookmark As Variant
Dim varBookmark1 As Variant
Dim varBookmark2 As Variant
Dim DDate1 As Date
Dim Str1 As String

Set db = CurrentDb

Set rst = db.OpenRecordset("Forecast")
Set rstd1 = db.OpenRecordset("First Date Set")
Set rstd2 = db.OpenRecordset("Second Date Set")
Set rstd3 = db.OpenRecordset("Third Date Set")
Set rst1 = db.OpenRecordset("4d")
Set rst2 = db.OpenRecordset("4d")
Set rst3 = db.OpenRecordset("4d")

With rstd1
.MoveFirst
Do Until .EOF
With rst1
DDate1 = rstd1!Date1
varBookmark = .Bookmark
.MoveLast
rst1.FindFirst "rst1!Date1 = rstd1!Date1"
Do While True
SeqA = rst1!Seq
NumA = rst1!Num1
DateA = rst1!Date1
OrigA = rst1!OrigNo
PriceA = rst1!Price
If .NoMatch Then
.Bookmark = varBookmark
Exit Do
End If
With rstd2
.MoveFirst
Do Until .EOF
With rst2
.MoveLast
varBookmark1 = .Bookmark
.FindFirst rst2!Date1 = rstd2!Date1
Do While True
SeqB = rst2!Seq
NumB = rst2!Num1
DateB = rst2!Date1
OrigB = rst2!OrigNo
PriceB = rst2!Price
If .NoMatch Then
.Bookmark = varBookmark1
Exit Do
End If
With rstd3
.MoveFirst
Do Until .EOF
With rst3
.MoveLast
varBookmark2 = .Bookmark
.FindFirst rst3!Date1 = rstd3!Date1
Do While True
rst.AddNew
rst!SeqA = SeqA
rst!SeqB = SeqB
rst!SeqC = rst3!Seq
rst!NumA = NumA
rst!NumB = NumB
rst!NumC = rst3!Num1
rst!DateA = DateA
rst!DateB = DateB
rst!DateC = rst3!Date1
rst!OrigA = OrigA
rst!OrigB = OrigB
rst!OrigC = rst3!OrigNo
rst!PriceA = PriceA
rst!PriceB = PriceB
rst!PriceC = rst3!Price
rst.Update
If .NoMatch Then
.Bookmark = varBookmark2
Exit Do
End If
.FindNext rst3!Date1 = rstd3!Date1
Loop
End With
.MoveNext
Loop
End With
.FindNext rst2!Date1 = rstd2!Date1
Loop
End With
.MoveNext
Loop
End With
.FindNext rst1!Date1 = rstd1!Date1
Loop
End With
.MoveNext
Loop
End With

rst.Close
rst1.Close
rst2.Close
rst3.Close
rstd1.Close
rstd2.Close
rstd3.Close

End Sub
'=====================

Regards
Benjamin
 
Benjamin,

Your code reads:

With rst1
DDate1 = rstd1!Date1
varBookmark = .Bookmark
.MoveLast
rst1.FindFirst "rst1!Date1 = rstd1!Date1"


Since you set DDate1 = rstd1!Date1, should the FindFirst line read
rst1.FindFirst "rst1!Date1 = " & DDate1

As I asked in a previous post, could you tell us what you are trying to do?

Kathryn


 
The .FindFirst method only applies to DAO's opened as dynasets. If you open a table with OpenRecordset, dynaset is not the default

Make the second paraneter to the OpenRecordset method the constant dbOpenDynaset, and this should take care of the problem. If I misspelled dbOpenDynaset, you can get the correct spelling by selecting the .FindFirst method and pressing the F1 key.

Best,

Harry Rich
 
I found this works best
I used to use this

Dim rs as Recordset

I got an error on the "rs.findfirst xxxxx" line
so I changed the
Dim rs as Recordset
to
Dim rs as DAO.Recodset

the error went away DougP, MCP
 
FindFirst syntax is not correct. Here is your snippet:

With rst2
.MoveLast
varBookmark1 = .Bookmark
.FindFirst rst2!Date1 = rstd2!Date1

'Recommended change
.FindFirst "Date1=#" & rstd2!Date1 & "#"
'You are already using a with construct for rst2
'and then repeating the rst2 in your FindFirst
'Also the criteria uses string data to search
'See the help example below
rst.FindFirst "SupplierID = " & strSearchName
If rst.NoMatch Then
MsgBox "Record not found"
End If
rst.Close

----------------------
Steve King
scking@arinc.com
Life is filled with lessons.
We are responsible for the
results of the quizzes.
-----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top