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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error with recordset's object find first... 3

Status
Not open for further replies.

Junior1544

Technical User
Apr 20, 2001
1,267
US
Here is some code i'm tring to get working...

I can't seem to get the findfirst to work right...

I've checked my vba references... and DAO 3.6 is checked...


ok, here's my module...

Thanks for taking a look at this...

--James


Sub work(File_Name As String)


On Err GoTo errorhandler

DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE Table1.* FROM Table1;"
DoCmd.SetWarnings True

DoCmd.TransferText acImportDelim, "ImportSpec", "table1", File_Name
Dim rst As DAO.Recordset
Dim strcriteria As String

Set rst = CurrentDb().OpenRecordset("table1")
rst.MoveLast
rst.MoveFirst

strcriteria = "F2 = 'tfc002'"

rst.FindFirst (strcriteria)
rst.MoveNext
rst.MoveNext
rst.MoveNext
rst.MoveNext
Debug.Print rst!f5

rst.Close
Set rst = Nothing
Exit Sub

errorhandler:
MsgBox Err.Number & " " & Err.Description
rst.Close
Set rst = Nothing



End Sub junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
you haven't furnished enuf to get help. What happened????


Rollie E
 
sorry, on the line :
rst.FindFirst (strcriteria)
it gives me an error number

3251 operation not suported for this type of object.

So don't know what to do to get findfirst to work...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
how many records are in the recordset? Is the recordset sorted? Are ther five records 'after' the find? Did the find work? These are answers that ought to be pursued first.

rollie@bwsys.net
 
there are about 1500 records in the recordset...

the recordset is not sorted there are many more records after the find...

the error i get is at the find... the code can't get past it...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
sorry aqbout that. DAO does not support findfirst. That is an ADO command. Try using the wizard and it will show you the DoCmd that is the equivalent. I just use the stabdard code to get to the find.

do while not rs.eof
if rs![F2] = 'tfc002' then
do something ....
exit do
endif


rs.movenext
loop

rollie@bwsys.net
 
DAO does support FindFirst and always has as far a I know. I've used it since 2.0. I think you are mixing Apples and Oranges. You don't normally see .Move with .Find in the same procedure. What exactly are you trying to do. If you can clarify that, someone can probably help provide you with a solution.
Paul
 
Replace:
Set rst = CurrentDb().OpenRecordset("table1")

with

Set rst = CurrentDb().OpenRecordset("Select * From table1;")

It will work

Good luck

[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Sorry, haven't explained why:

It sounds like your recordset opens as table type.
On a table type recordset you'll have to use Seek, not Find...

My personal preference is to force all recordsets to open as Dynasets and use Find methods.

And Junior, another thing... Split your database (wonder how I know it's not?[smile])


[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Yea, i do wonder how you know it's not... and i'm just in the development part... so i was working with it not split so that when i move around i just have to have one file folow me...

Thanks...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
OK: A recordset opens as TableType only if it's native. If it were linked, it would open as Dynaset by default and allow you to use FindFirst, Next...

You could check for the recordset type by using:
Debug.Print rst.Type
It would return the numeric value of dbOpenTable constant...

Set rst = CurrentDb().OpenRecordset("table1", dbOpenDynaset)
is another way to force its type.


Sorry for the 'Junior' thing, I didn't see the 'James' signature, but only the nick junior1544...

So, James, regards and have a nice weekend (as I will surely have[smile])
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Thanks Daniel,

I hope this star will add to your nice weekend:)

Thank you...

--James junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top