Connecting Tech Pros Worldwide Forums | Help | Site Map

Error 3251, Recordsets !@#$%^&*()

Frusterated
Guest
 
Posts: n/a
#1: Nov 12 '05
Hi,
I'm using Access-2k under Win-XP...
When I have a form with imbedded code it works perfect. Such as the
following code example.

Dim db as DAO.Database
Dim rs as DAO.Recordset

Set db = CurrentDB
set rs = db.OpenRecordset("MyTable")
rs.FindFirst "UPC=" & upcno

BUT, when I use this same code in a module outside of any form I get the
following message:

Run-time error 3251
Operation is not supported for this kind of object.

I usually get around this problem by removing the "FindFirst" and
sequentially searching until I find the record in question. But I am
missing something in my understanding of Recordset Objects.
Please help me clear this up.

TIA
Tim Hunter




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tom van Stiphout
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Error 3251, Recordsets !@#$%^&*()


On 18 Oct 2003 15:51:28 GMT, Frusterated <Frusterated@AccessHelp.com>
wrote:

Assuming upcno is a variable passed into your function and not a field
reference that is no longer valid, and not of the wrong datatype
(should be numeric), then your code looks fine, and your machine may
be screwed up. Try it on another machine. Load the latest service
packs.

-Tom.

[color=blue]
>Hi,
>I'm using Access-2k under Win-XP...
>When I have a form with imbedded code it works perfect. Such as the
>following code example.
>
>Dim db as DAO.Database
>Dim rs as DAO.Recordset
>
>Set db = CurrentDB
>set rs = db.OpenRecordset("MyTable")
>rs.FindFirst "UPC=" & upcno
>
>BUT, when I use this same code in a module outside of any form I get the
>following message:
>
>Run-time error 3251
>Operation is not supported for this kind of object.
>
>I usually get around this problem by removing the "FindFirst" and
>sequentially searching until I find the record in question. But I am
>missing something in my understanding of Recordset Objects.
>Please help me clear this up.
>
>TIA
>Tim Hunter
>
>
>
>
>*** Sent via Developersdex http://www.developersdex.com ***
>Don't just participate in USENET...get rewarded for it![/color]

TC
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Error 3251, Recordsets !@#$%^&*()


If MyTable is a *linked* table, you have to use the dbOpenDynaset parameter
on the openrecordset call if you want to use the Seek?...Find? methods on
that recordset. I don't remember which, & I don't have Access here to check.
Try that change & see if it helps.

HTH,
TC


"Frusterated" <Frusterated@AccessHelp.com> wrote in message
news:3f91617f$0$200$75868355@news.frii.net...[color=blue]
> Hi,
> I'm using Access-2k under Win-XP...
> When I have a form with imbedded code it works perfect. Such as the
> following code example.
>
> Dim db as DAO.Database
> Dim rs as DAO.Recordset
>
> Set db = CurrentDB
> set rs = db.OpenRecordset("MyTable")
> rs.FindFirst "UPC=" & upcno
>
> BUT, when I use this same code in a module outside of any form I get the
> following message:
>
> Run-time error 3251
> Operation is not supported for this kind of object.
>
> I usually get around this problem by removing the "FindFirst" and
> sequentially searching until I find the record in question. But I am
> missing something in my understanding of Recordset Objects.
> Please help me clear this up.
>
> TIA
> Tim Hunter
>
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it![/color]


Tom van Stiphout
Guest
 
Posts: n/a
#4: Nov 12 '05

re: Error 3251, Recordsets !@#$%^&*()


On Sun, 19 Oct 2003 17:32:32 +1200, "TC" <a@b.c.d> wrote:

I think OpenDynaset is the default, if you don't specify the argument.

Seek does not work on attached tables. If you want to use it, you need
to first open a database object representing the backend database.

However, Tim is using FindFirst, which should work in all situations.

-Tom.

[color=blue]
>If MyTable is a *linked* table, you have to use the dbOpenDynaset parameter
>on the openrecordset call if you want to use the Seek?...Find? methods on
>that recordset. I don't remember which, & I don't have Access here to check.
>Try that change & see if it helps.
>
>HTH,
>TC
>
>
>"Frusterated" <Frusterated@AccessHelp.com> wrote in message
>news:3f91617f$0$200$75868355@news.frii.net...[color=green]
>> Hi,
>> I'm using Access-2k under Win-XP...
>> When I have a form with imbedded code it works perfect. Such as the
>> following code example.
>>
>> Dim db as DAO.Database
>> Dim rs as DAO.Recordset
>>
>> Set db = CurrentDB
>> set rs = db.OpenRecordset("MyTable")
>> rs.FindFirst "UPC=" & upcno
>>
>> BUT, when I use this same code in a module outside of any form I get the
>> following message:
>>
>> Run-time error 3251
>> Operation is not supported for this kind of object.
>>
>> I usually get around this problem by removing the "FindFirst" and
>> sequentially searching until I find the record in question. But I am
>> missing something in my understanding of Recordset Objects.
>> Please help me clear this up.
>>
>> TIA
>> Tim Hunter
>>
>>
>>
>>
>> *** Sent via Developersdex http://www.developersdex.com ***
>> Don't just participate in USENET...get rewarded for it![/color]
>[/color]

TC
Guest
 
Posts: n/a
#5: Nov 12 '05

re: Error 3251, Recordsets !@#$%^&*()


That's not how I remember it, but I don't have Access here to check, so you
may well be right. I'll try it tonight, & confirm it (one way to the other)
tomorrow.

TC


"Tom van Stiphout" <tom7744@no.spam.cox.net> wrote in message
news:gep5pv8eu8a1nkll1i44t9v8t5ad9vknuj@4ax.com...[color=blue]
> On Sun, 19 Oct 2003 17:32:32 +1200, "TC" <a@b.c.d> wrote:
>
> I think OpenDynaset is the default, if you don't specify the argument.
>
> Seek does not work on attached tables. If you want to use it, you need
> to first open a database object representing the backend database.
>
> However, Tim is using FindFirst, which should work in all situations.
>
> -Tom.
>
>[color=green]
> >If MyTable is a *linked* table, you have to use the dbOpenDynaset[/color][/color]
parameter[color=blue][color=green]
> >on the openrecordset call if you want to use the Seek?...Find? methods on
> >that recordset. I don't remember which, & I don't have Access here to[/color][/color]
check.[color=blue][color=green]
> >Try that change & see if it helps.
> >
> >HTH,
> >TC
> >
> >
> >"Frusterated" <Frusterated@AccessHelp.com> wrote in message
> >news:3f91617f$0$200$75868355@news.frii.net...[color=darkred]
> >> Hi,
> >> I'm using Access-2k under Win-XP...
> >> When I have a form with imbedded code it works perfect. Such as the
> >> following code example.
> >>
> >> Dim db as DAO.Database
> >> Dim rs as DAO.Recordset
> >>
> >> Set db = CurrentDB
> >> set rs = db.OpenRecordset("MyTable")
> >> rs.FindFirst "UPC=" & upcno
> >>
> >> BUT, when I use this same code in a module outside of any form I get[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> >> following message:
> >>
> >> Run-time error 3251
> >> Operation is not supported for this kind of object.
> >>
> >> I usually get around this problem by removing the "FindFirst" and
> >> sequentially searching until I find the record in question. But I am
> >> missing something in my understanding of Recordset Objects.
> >> Please help me clear this up.
> >>
> >> TIA
> >> Tim Hunter
> >>
> >>
> >>
> >>
> >> *** Sent via Developersdex http://www.developersdex.com ***
> >> Don't just participate in USENET...get rewarded for it![/color]
> >[/color]
>[/color]


Frusterated
Guest
 
Posts: n/a
#6: Nov 12 '05

re: Error 3251, Recordsets !@#$%^&*()



Hi,
I want to clarify a few points per your responses. First, this is not a
linked table now, but it will be when this application is finished.
Second, I have all current updates to WinXP as well as Office-2k. Third,
I have another computer that runs Win2k and the application behaves the
same. Fourth, this is not a new problem. I have had this problem many
times before and I just got around it by not using the FindFirst
thinking that there was something that I was missing in my understanding
of Access. This time I decided to see if I could solve this annoyance
once and for all. I appreciate all your responses and I just wanted to
make sure I have provided enough information.

TIA



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
David W. Fenton
Guest
 
Posts: n/a
#7: Nov 12 '05

re: Error 3251, Recordsets !@#$%^&*()


Frusterated@AccessHelp.com (Frusterated) wrote in
<3f945681$0$197$75868355@news.frii.net>:
[color=blue]
>I want to clarify a few points per your responses. First, this is
>not a linked table now, but it will be when this application is
>finished. Second, I have all current updates to WinXP as well as
>Office-2k. Third, I have another computer that runs Win2k and the
>application behaves the same. Fourth, this is not a new problem. I
>have had this problem many times before and I just got around it
>by not using the FindFirst thinking that there was something that
>I was missing in my understanding of Access. This time I decided
>to see if I could solve this annoyance once and for all. I
>appreciate all your responses and I just wanted to make sure I
>have provided enough information.[/color]

Are you sure you need .FindFirst, and not just a recordset with an
appropriately chosen WHERE clause?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Larry Linson
Guest
 
Posts: n/a
#8: Nov 12 '05

re: Error 3251, Recordsets !@#$%^&*()


Please clarify what "upcno" represents: a Public variable, an argument
passed in to the procedure, or a control on a form.

That is, quite possibly, the source of your problem, particularly if it is
the last of the three -- could be referenced in the Form's module, but not,
in that way, in a standard module.

Also, you show no test to determine if any records were returned before
trying the FindFirst... though perhaps you omitted that code for simplicity.

Larry Linson
Microsoft Access MVP



"Frusterated" <Frusterated@AccessHelp.com> wrote in message
news:3f945681$0$197$75868355@news.frii.net...[color=blue]
>
> Hi,
> I want to clarify a few points per your responses. First, this is not a
> linked table now, but it will be when this application is finished.
> Second, I have all current updates to WinXP as well as Office-2k. Third,
> I have another computer that runs Win2k and the application behaves the
> same. Fourth, this is not a new problem. I have had this problem many
> times before and I just got around it by not using the FindFirst
> thinking that there was something that I was missing in my understanding
> of Access. This time I decided to see if I could solve this annoyance
> once and for all. I appreciate all your responses and I just wanted to
> make sure I have provided enough information.
>
> TIA
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it![/color]


TC
Guest
 
Posts: n/a
#9: Nov 12 '05

re: Error 3251, Recordsets !@#$%^&*()


Ah, this is what I was thinking of:

If you openrecordset without the mode parameter, & the table is
linked, you get dbopendynaset by default, so the FindX methods work.
But if you move the table to local - perhaps to handle a multiuser
concurrency issue - the openrecordset defaults to dbopentable, so the
FindX methods stop working. Then you must go back & add the
dbopendynaset.

So a good rule probably is, when working in a fe/be environment, to
always specify the desired mode (dbopentable or dbopendynaset) when
you openrecordset. Then, if the mode is inconsistent with the table
location (linked vs local), the error will occur as soon as possible
(ie. on the openrecordset), instead of causing problems later on, eg.
on a FindX method.

TC


"TC" <a@b.c.d> wrote in message news:<1066623539.725775@teuthos>...[color=blue]
> That's not how I remember it, but I don't have Access here to check, so you
> may well be right. I'll try it tonight, & confirm it (one way to the other)
> tomorrow.
>
> TC
>
>
> "Tom van Stiphout" <tom7744@no.spam.cox.net> wrote in message
> news:gep5pv8eu8a1nkll1i44t9v8t5ad9vknuj@4ax.com...[color=green]
> > On Sun, 19 Oct 2003 17:32:32 +1200, "TC" <a@b.c.d> wrote:
> >
> > I think OpenDynaset is the default, if you don't specify the argument.
> >
> > Seek does not work on attached tables. If you want to use it, you need
> > to first open a database object representing the backend database.
> >
> > However, Tim is using FindFirst, which should work in all situations.
> >
> > -Tom.
> >
> >[color=darkred]
> > >If MyTable is a *linked* table, you have to use the dbOpenDynaset[/color][/color]
> parameter[color=green][color=darkred]
> > >on the openrecordset call if you want to use the Seek?...Find? methods on
> > >that recordset. I don't remember which, & I don't have Access here to[/color][/color]
> check.[color=green][color=darkred]
> > >Try that change & see if it helps.
> > >
> > >HTH,
> > >TC
> > >
> > >
> > >"Frusterated" <Frusterated@AccessHelp.com> wrote in message
> > >news:3f91617f$0$200$75868355@news.frii.net...
> > >> Hi,
> > >> I'm using Access-2k under Win-XP...
> > >> When I have a form with imbedded code it works perfect. Such as the
> > >> following code example.
> > >>
> > >> Dim db as DAO.Database
> > >> Dim rs as DAO.Recordset
> > >>
> > >> Set db = CurrentDB
> > >> set rs = db.OpenRecordset("MyTable")
> > >> rs.FindFirst "UPC=" & upcno
> > >>
> > >> BUT, when I use this same code in a module outside of any form I get[/color][/color]
> the[color=green][color=darkred]
> > >> following message:
> > >>
> > >> Run-time error 3251
> > >> Operation is not supported for this kind of object.
> > >>
> > >> I usually get around this problem by removing the "FindFirst" and
> > >> sequentially searching until I find the record in question. But I am
> > >> missing something in my understanding of Recordset Objects.
> > >> Please help me clear this up.
> > >>
> > >> TIA
> > >> Tim Hunter
> > >>
> > >>
> > >>
> > >>
> > >> *** Sent via Developersdex http://www.developersdex.com ***
> > >> Don't just participate in USENET...get rewarded for it!
> > >[/color]
> >[/color][/color]
Frusterated
Guest
 
Posts: n/a
#10: Nov 12 '05

re: Error 3251, Recordsets !@#$%^&*()


OK, I submitted code as an example of my problem but I see I left a few
things out and it has caused some confusion. Below I have inserted new
code as a test that consistantly gives me the 3251 error. This code is
in a module and is executed by itself for test purposes. I am not sure
but I believe my problem is related to opening a Recordset outside of a
form....TIA

Public Sub test()
Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("RstInventory")
rs.FindFirst "UPC=9202098"
If rs.NoMatch Then
MsgBox "No match...", vbCritical
Else
MsgBox "It worked...", vbCritical
End If
rs.Close
End Sub






*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
TC
Guest
 
Posts: n/a
#11: Nov 12 '05

re: Error 3251, Recordsets !@#$%^&*()


You say elsewhere: "this is not a linked table now". If so, then, your
openrecordset statement is creating a so-called "table" recordset, by
default. You can not use the Find<whatever> methods with a table recordset.
You need a so-called "dynaset" recordset. Change your openrecordset
statement to this:

Set rs = db.OpenRecordset("RstInventory", dbOpenDynaset)

HTH,
TC



"Frusterated" <Frusterated@AccessHelp.com> wrote in message
news:3f959a02$0$197$75868355@news.frii.net...[color=blue]
> OK, I submitted code as an example of my problem but I see I left a few
> things out and it has caused some confusion. Below I have inserted new
> code as a test that consistantly gives me the 3251 error. This code is
> in a module and is executed by itself for test purposes. I am not sure
> but I believe my problem is related to opening a Recordset outside of a
> form....TIA
>
> Public Sub test()
> Dim db As DAO.Database
> Dim rs As DAO.Recordset
>
> Set db = CurrentDb
> Set rs = db.OpenRecordset("RstInventory")
> rs.FindFirst "UPC=9202098"
> If rs.NoMatch Then
> MsgBox "No match...", vbCritical
> Else
> MsgBox "It worked...", vbCritical
> End If
> rs.Close
> End Sub
>
>
>
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it![/color]


Closed Thread