By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,208 Members | 1,072 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,208 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!
Nov 12 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
On 18 Oct 2003 15:51:28 GMT, Frusterated <Fr*********@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.

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!


Nov 12 '05 #2

P: n/a
TC
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" <Fr*********@AccessHelp.com> wrote in message
news:3f*********************@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 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!

Nov 12 '05 #3

P: n/a
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.

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" <Fr*********@AccessHelp.com> wrote in message
news:3f*********************@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 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!


Nov 12 '05 #4

P: n/a
TC
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" <to*****@no.spam.cox.net> wrote in message
news:ge********************************@4ax.com...
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.

If MyTable is a *linked* table, you have to use the dbOpenDynaset parameteron 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" <Fr*********@AccessHelp.com> wrote in message
news:3f*********************@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 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!

Nov 12 '05 #5

P: n/a

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!
Nov 12 '05 #6

P: n/a
Fr*********@AccessHelp.com (Frusterated) wrote in
<3f*********************@news.frii.net>:
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.


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
Nov 12 '05 #7

P: n/a
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" <Fr*********@AccessHelp.com> wrote in message
news:3f*********************@news.frii.net...

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!

Nov 12 '05 #8

P: n/a
TC
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>...
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" <to*****@no.spam.cox.net> wrote in message
news:ge********************************@4ax.com...
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.

If MyTable is a *linked* table, you have to use the dbOpenDynaset parameteron 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" <Fr*********@AccessHelp.com> wrote in message
news:3f*********************@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 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!

Nov 12 '05 #9

P: n/a
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!
Nov 12 '05 #10

P: n/a
TC
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" <Fr*********@AccessHelp.com> wrote in message
news:3f*********************@news.frii.net...
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!

Nov 12 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.