This is a multi-part message in MIME format.

------=_NextPart_000_0008_01C45933.30136C80
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I'm trying to use a recordset inside of a function but I'm getting an =
"object required 'adoRS" error. =20

At the top of the page I create my recordset, ex:

dim strConnection, adoCN, adoRS, strSQL

strConnection =3D <Connection>
Set adoCN =3D server.CreateObject("ADODB.connection")
Set adoRS =3D server.CreateObject("ADODB.recordset")
adoCN.Open strConnection
adoRS.ActiveConnection =3D adoCN
adoRS.CursorLocation =3D adUseClient

strSQL =3D "SELECT ... "
adoRS.open strSQL

then further down the page I call a function GetRecords(). The function =
looks like this:

function GetRecords()
adoRS.movefirst
var1 =3D adoRS("field1")
...........etc
end function

I'd rather not have the whole recordset inside of the function since I =
also use it on other parts of the page. What am I doing wrong?

Thanks
------=_NextPart_000_0008_01C45933.30136C80
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>I'm trying to use a recordset inside of a function =
but I'm=20
getting an "object required 'adoRS" error.&nbsp; </FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>At the top of the page I create my recordset, =
ex:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>dim strConnection, adoCN, adoRS, strSQL</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>strConnection =3D &lt;Connection&gt;<BR>Set adoCN =
=3D=20
server.CreateObject("ADODB.connection")<BR>Set adoRS =3D=20
server.CreateObject("ADODB.recordset")<BR>adoCN.Open=20
strConnection<BR>adoRS.ActiveConnection =3D =
adoCN<BR>adoRS.CursorLocation =3D=20
adUseClient</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>strSQL =3D "SELECT ... "</FONT></DIV>
<DIV><FONT size=3D2>adoRS.open strSQL</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>then further down the page I call a function=20
GetRecords().&nbsp; The function looks like this:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>function GetRecords()</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; adoRS.movefirst</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; var1 =3D =
adoRS("field1")</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
...........etc</FONT></DIV>
<DIV><FONT size=3D2>end function</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I'd rather not have the whole recordset inside of =
the function=20
since I also use it on other parts of the page.&nbsp;What am I doing=20
wrong?</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Thanks</FONT></DIV></BODY></HTML>

------=_NextPart_000_0008_01C45933.30136C80--

Re: Use a recordset inside a Function? by Bob

Bob
Wed Jun 23 14:47:10 CDT 2004

[Please don't post in HTML]

I don't see anything wrong. Perhaps if you showed us which line generates
the error ...

I do have some suggestions which I will put inline

Bob Barrows

"David Berry" <dberry@mvps.org> wrote in message
news:ufZZ4SVWEHA.556@tk2msftngp13.phx.gbl...
> I'm trying to use a recordset inside of a function but I'm getting an
"object required 'adoRS" error.
>
> At the top of the page I create my recordset, ex:
>
> dim strConnection, adoCN, adoRS, strSQL
>
> strConnection = <Connection>
> Set adoCN = server.CreateObject("ADODB.connection")
> Set adoRS = server.CreateObject("ADODB.recordset")
> adoCN.Open strConnection
> adoRS.ActiveConnection = adoCN

This line is unnecessary. If forced to use it, it should be as follows
Set adoRS.ActiveConnection = adoCN

>
> adoRS.CursorLocation = adUseClient
>
> strSQL = "SELECT ... "
> adoRS.open strSQL
>

If you get rid of the "Set adoRS.ActiveConnection ... " line, then you need
to change this to
adoRS.open strSQL,adoCN,,,adCmdText

Otherwise, it should be:
adoRS.open strSQL,,,,adCmdText

> then further down the page I call a function GetRecords(). The function
looks like this:
>
> function GetRecords()
> adoRS.movefirst
> var1 = adoRS("field1")
> ...........etc
> end function

Again, nothing sticks out. Is this function in the same script block? You
haven't tried to use a server-side object in a client-side script block,
have you?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From header is
my spam trap, so I don't check it very often. You will get a quicker
response by posting to the newsgroup.



Re: Use a recordset inside a Function? by David

David
Wed Jun 23 14:56:00 CDT 2004

Hi Bob. The line that generates the error is adoRS.movefirst however if I
remove that, ANY line that references the recordset generates the error.
For example: var1= adoRS("Field1") would generate the error.

function GetRecords()
---->>> adoRS.movefirst
var1 = adoRS("field1")
...........etc
end function

Code that creates the recordset is in a script block at the top of the page
and the function is in a script block about half way down the page. I'm
calling the function near the end of the page. Getting rid of the Set
adoRS.ActiveConnection line and changing it has no effect.


"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:uP1KlrVWEHA.2340@TK2MSFTNGP09.phx.gbl...
> [Please don't post in HTML]
>
> I don't see anything wrong. Perhaps if you showed us which line generates
> the error ...
>
> I do have some suggestions which I will put inline
>
> Bob Barrows
>
> "David Berry" <dberry@mvps.org> wrote in message
> news:ufZZ4SVWEHA.556@tk2msftngp13.phx.gbl...
> > I'm trying to use a recordset inside of a function but I'm getting an
> "object required 'adoRS" error.
> >
> > At the top of the page I create my recordset, ex:
> >
> > dim strConnection, adoCN, adoRS, strSQL
> >
> > strConnection = <Connection>
> > Set adoCN = server.CreateObject("ADODB.connection")
> > Set adoRS = server.CreateObject("ADODB.recordset")
> > adoCN.Open strConnection
> > adoRS.ActiveConnection = adoCN
>
> This line is unnecessary. If forced to use it, it should be as follows
> Set adoRS.ActiveConnection = adoCN
>
> >
> > adoRS.CursorLocation = adUseClient
> >
> > strSQL = "SELECT ... "
> > adoRS.open strSQL
> >
>
> If you get rid of the "Set adoRS.ActiveConnection ... " line, then you
need
> to change this to
> adoRS.open strSQL,adoCN,,,adCmdText
>
> Otherwise, it should be:
> adoRS.open strSQL,,,,adCmdText
>
> > then further down the page I call a function GetRecords(). The function
> looks like this:
> >
> > function GetRecords()
> > adoRS.movefirst
> > var1 = adoRS("field1")
> > ...........etc
> > end function
>
> Again, nothing sticks out. Is this function in the same script block? You
> haven't tried to use a server-side object in a client-side script block,
> have you?
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From header
is
> my spam trap, so I don't check it very often. You will get a quicker
> response by posting to the newsgroup.
>
>



Re: Use a recordset inside a Function? by David

David
Wed Jun 23 15:00:39 CDT 2004

PS - there's no client side code or script block on the page



"David Berry" <dberry@mvps.org> wrote in message
news:euw2cwVWEHA.808@tk2msftngp13.phx.gbl...
> Hi Bob. The line that generates the error is adoRS.movefirst however if I
> remove that, ANY line that references the recordset generates the error.
> For example: var1= adoRS("Field1") would generate the error.
>
> function GetRecords()
> ---->>> adoRS.movefirst
> var1 = adoRS("field1")
> ...........etc
> end function
>
> Code that creates the recordset is in a script block at the top of the
page
> and the function is in a script block about half way down the page. I'm
> calling the function near the end of the page. Getting rid of the Set
> adoRS.ActiveConnection line and changing it has no effect.
>
>
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:uP1KlrVWEHA.2340@TK2MSFTNGP09.phx.gbl...
> > [Please don't post in HTML]
> >
> > I don't see anything wrong. Perhaps if you showed us which line
generates
> > the error ...
> >
> > I do have some suggestions which I will put inline
> >
> > Bob Barrows
> >
> > "David Berry" <dberry@mvps.org> wrote in message
> > news:ufZZ4SVWEHA.556@tk2msftngp13.phx.gbl...
> > > I'm trying to use a recordset inside of a function but I'm getting an
> > "object required 'adoRS" error.
> > >
> > > At the top of the page I create my recordset, ex:
> > >
> > > dim strConnection, adoCN, adoRS, strSQL
> > >
> > > strConnection = <Connection>
> > > Set adoCN = server.CreateObject("ADODB.connection")
> > > Set adoRS = server.CreateObject("ADODB.recordset")
> > > adoCN.Open strConnection
> > > adoRS.ActiveConnection = adoCN
> >
> > This line is unnecessary. If forced to use it, it should be as follows
> > Set adoRS.ActiveConnection = adoCN
> >
> > >
> > > adoRS.CursorLocation = adUseClient
> > >
> > > strSQL = "SELECT ... "
> > > adoRS.open strSQL
> > >
> >
> > If you get rid of the "Set adoRS.ActiveConnection ... " line, then you
> need
> > to change this to
> > adoRS.open strSQL,adoCN,,,adCmdText
> >
> > Otherwise, it should be:
> > adoRS.open strSQL,,,,adCmdText
> >
> > > then further down the page I call a function GetRecords(). The
function
> > looks like this:
> > >
> > > function GetRecords()
> > > adoRS.movefirst
> > > var1 = adoRS("field1")
> > > ...........etc
> > > end function
> >
> > Again, nothing sticks out. Is this function in the same script block?
You
> > haven't tried to use a server-side object in a client-side script block,
> > have you?
> >
> > --
> > Microsoft MVP -- ASP/ASP.NET
> > Please reply to the newsgroup. The email account listed in my From
header
> is
> > my spam trap, so I don't check it very often. You will get a quicker
> > response by posting to the newsgroup.
> >
> >
>
>



Re: Use a recordset inside a Function? by Bob

Bob
Wed Jun 23 15:15:55 CDT 2004

1. Try declaring the function higher up on the page.
2. Try passing the recordset to the function instead of using the global
variable. I.E.,

adoRs.open ...
...
GetRecords(adoRS)


Function GetRecords(pRS)
if not pRS.BOF then pRS.MoveFirst
'etc.
End Function



David Berry wrote:
> PS - there's no client side code or script block on the page
>
>
>
> "David Berry" <dberry@mvps.org> wrote in message
> news:euw2cwVWEHA.808@tk2msftngp13.phx.gbl...
>> Hi Bob. The line that generates the error is adoRS.movefirst
>> however if I remove that, ANY line that references the recordset
>> generates the error. For example: var1= adoRS("Field1") would
>> generate the error.
>>
>> function GetRecords()
>> ---->>> adoRS.movefirst
>> var1 = adoRS("field1")
>> ...........etc
>> end function
>>
>> Code that creates the recordset is in a script block at the top of
>> the page and the function is in a script block about half way down
>> the page. I'm calling the function near the end of the page.
>> Getting rid of the Set adoRS.ActiveConnection line and changing it
>> has no effect.
>>
>>
>> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
>> news:uP1KlrVWEHA.2340@TK2MSFTNGP09.phx.gbl...
>>> [Please don't post in HTML]
>>>
>>> I don't see anything wrong. Perhaps if you showed us which line
>>> generates the error ...
>>>
>>> I do have some suggestions which I will put inline
>>>
>>> Bob Barrows
>>>
>>> "David Berry" <dberry@mvps.org> wrote in message
>>> news:ufZZ4SVWEHA.556@tk2msftngp13.phx.gbl...
>>>> I'm trying to use a recordset inside of a function but I'm getting
>>>> an
>>> "object required 'adoRS" error.
>>>>
>>>> At the top of the page I create my recordset, ex:
>>>>
>>>> dim strConnection, adoCN, adoRS, strSQL
>>>>
>>>> strConnection = <Connection>
>>>> Set adoCN = server.CreateObject("ADODB.connection")
>>>> Set adoRS = server.CreateObject("ADODB.recordset")
>>>> adoCN.Open strConnection
>>>> adoRS.ActiveConnection = adoCN
>>>
>>> This line is unnecessary. If forced to use it, it should be as
>>> follows Set adoRS.ActiveConnection = adoCN
>>>
>>>>
>>>> adoRS.CursorLocation = adUseClient
>>>>
>>>> strSQL = "SELECT ... "
>>>> adoRS.open strSQL
>>>>
>>>
>>> If you get rid of the "Set adoRS.ActiveConnection ... " line, then
>>> you need to change this to
>>> adoRS.open strSQL,adoCN,,,adCmdText
>>>
>>> Otherwise, it should be:
>>> adoRS.open strSQL,,,,adCmdText
>>>
>>>> then further down the page I call a function GetRecords(). The
>>>> function looks like this:
>>>>
>>>> function GetRecords()
>>>> adoRS.movefirst
>>>> var1 = adoRS("field1")
>>>> ...........etc
>>>> end function
>>>
>>> Again, nothing sticks out. Is this function in the same script
>>> block? You haven't tried to use a server-side object in a
>>> client-side script block, have you?
>>>
>>> --
>>> Microsoft MVP -- ASP/ASP.NET
>>> Please reply to the newsgroup. The email account listed in my From
>>> header is my spam trap, so I don't check it very often. You will
>>> get a quicker response by posting to the newsgroup.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.



Re: Use a recordset inside a Function? by David

David
Wed Jun 23 15:26:19 CDT 2004

Hi Bob. I just tried both those and I still get object required 'pRS'



"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:er4lp7VWEHA.3476@tk2msftngp13.phx.gbl...
> 1. Try declaring the function higher up on the page.
> 2. Try passing the recordset to the function instead of using the global
> variable. I.E.,
>
> adoRs.open ...
> ...
> GetRecords(adoRS)
>
>
> Function GetRecords(pRS)
> if not pRS.BOF then pRS.MoveFirst
> 'etc.
> End Function
>
>
>
> David Berry wrote:
> > PS - there's no client side code or script block on the page
> >
> >
> >
> > "David Berry" <dberry@mvps.org> wrote in message
> > news:euw2cwVWEHA.808@tk2msftngp13.phx.gbl...
> >> Hi Bob. The line that generates the error is adoRS.movefirst
> >> however if I remove that, ANY line that references the recordset
> >> generates the error. For example: var1= adoRS("Field1") would
> >> generate the error.
> >>
> >> function GetRecords()
> >> ---->>> adoRS.movefirst
> >> var1 = adoRS("field1")
> >> ...........etc
> >> end function
> >>
> >> Code that creates the recordset is in a script block at the top of
> >> the page and the function is in a script block about half way down
> >> the page. I'm calling the function near the end of the page.
> >> Getting rid of the Set adoRS.ActiveConnection line and changing it
> >> has no effect.
> >>
> >>
> >> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> >> news:uP1KlrVWEHA.2340@TK2MSFTNGP09.phx.gbl...
> >>> [Please don't post in HTML]
> >>>
> >>> I don't see anything wrong. Perhaps if you showed us which line
> >>> generates the error ...
> >>>
> >>> I do have some suggestions which I will put inline
> >>>
> >>> Bob Barrows
> >>>
> >>> "David Berry" <dberry@mvps.org> wrote in message
> >>> news:ufZZ4SVWEHA.556@tk2msftngp13.phx.gbl...
> >>>> I'm trying to use a recordset inside of a function but I'm getting
> >>>> an
> >>> "object required 'adoRS" error.
> >>>>
> >>>> At the top of the page I create my recordset, ex:
> >>>>
> >>>> dim strConnection, adoCN, adoRS, strSQL
> >>>>
> >>>> strConnection = <Connection>
> >>>> Set adoCN = server.CreateObject("ADODB.connection")
> >>>> Set adoRS = server.CreateObject("ADODB.recordset")
> >>>> adoCN.Open strConnection
> >>>> adoRS.ActiveConnection = adoCN
> >>>
> >>> This line is unnecessary. If forced to use it, it should be as
> >>> follows Set adoRS.ActiveConnection = adoCN
> >>>
> >>>>
> >>>> adoRS.CursorLocation = adUseClient
> >>>>
> >>>> strSQL = "SELECT ... "
> >>>> adoRS.open strSQL
> >>>>
> >>>
> >>> If you get rid of the "Set adoRS.ActiveConnection ... " line, then
> >>> you need to change this to
> >>> adoRS.open strSQL,adoCN,,,adCmdText
> >>>
> >>> Otherwise, it should be:
> >>> adoRS.open strSQL,,,,adCmdText
> >>>
> >>>> then further down the page I call a function GetRecords(). The
> >>>> function looks like this:
> >>>>
> >>>> function GetRecords()
> >>>> adoRS.movefirst
> >>>> var1 = adoRS("field1")
> >>>> ...........etc
> >>>> end function
> >>>
> >>> Again, nothing sticks out. Is this function in the same script
> >>> block? You haven't tried to use a server-side object in a
> >>> client-side script block, have you?
> >>>
> >>> --
> >>> Microsoft MVP -- ASP/ASP.NET
> >>> Please reply to the newsgroup. The email account listed in my From
> >>> header is my spam trap, so I don't check it very often. You will
> >>> get a quicker response by posting to the newsgroup.
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>



Re: Use a recordset inside a Function? by Bob

Bob
Wed Jun 23 16:33:03 CDT 2004

Well, I'm stumped. Is there any chance of posting an abbreviated version of
your page in which this error can be reproduced? Use the Northwind sample
database so we don't have to worry about getting sample data from you.

Bob Barrows

David Berry wrote:
> Hi Bob. I just tried both those and I still get object required 'pRS'
>
>
>
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:er4lp7VWEHA.3476@tk2msftngp13.phx.gbl...
>> 1. Try declaring the function higher up on the page.
>> 2. Try passing the recordset to the function instead of using the
>> global variable. I.E.,
>>
>> adoRs.open ...
>> ...
>> GetRecords(adoRS)
>>
>>
>> Function GetRecords(pRS)
>> if not pRS.BOF then pRS.MoveFirst
>> 'etc.
>> End Function
>>
>>
>>
>> David Berry wrote:
>>> PS - there's no client side code or script block on the page
>>>
>>>
>>>
>>> "David Berry" <dberry@mvps.org> wrote in message
>>> news:euw2cwVWEHA.808@tk2msftngp13.phx.gbl...
>>>> Hi Bob. The line that generates the error is adoRS.movefirst
>>>> however if I remove that, ANY line that references the recordset
>>>> generates the error. For example: var1= adoRS("Field1") would
>>>> generate the error.
>>>>
>>>> function GetRecords()
>>>> ---->>> adoRS.movefirst
>>>> var1 = adoRS("field1")
>>>> ...........etc
>>>> end function
>>>>
>>>> Code that creates the recordset is in a script block at the top of
>>>> the page and the function is in a script block about half way down
>>>> the page. I'm calling the function near the end of the page.
>>>> Getting rid of the Set adoRS.ActiveConnection line and changing it
>>>> has no effect.
>>>>
>>>>
>>>> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
>>>> news:uP1KlrVWEHA.2340@TK2MSFTNGP09.phx.gbl...
>>>>> [Please don't post in HTML]
>>>>>
>>>>> I don't see anything wrong. Perhaps if you showed us which line
>>>>> generates the error ...
>>>>>
>>>>> I do have some suggestions which I will put inline
>>>>>
>>>>> Bob Barrows
>>>>>
>>>>> "David Berry" <dberry@mvps.org> wrote in message
>>>>> news:ufZZ4SVWEHA.556@tk2msftngp13.phx.gbl...
>>>>>> I'm trying to use a recordset inside of a function but I'm
>>>>>> getting an
>>>>> "object required 'adoRS" error.
>>>>>>
>>>>>> At the top of the page I create my recordset, ex:
>>>>>>
>>>>>> dim strConnection, adoCN, adoRS, strSQL
>>>>>>
>>>>>> strConnection = <Connection>
>>>>>> Set adoCN = server.CreateObject("ADODB.connection")
>>>>>> Set adoRS = server.CreateObject("ADODB.recordset")
>>>>>> adoCN.Open strConnection
>>>>>> adoRS.ActiveConnection = adoCN
>>>>>
>>>>> This line is unnecessary. If forced to use it, it should be as
>>>>> follows Set adoRS.ActiveConnection = adoCN
>>>>>
>>>>>>
>>>>>> adoRS.CursorLocation = adUseClient
>>>>>>
>>>>>> strSQL = "SELECT ... "
>>>>>> adoRS.open strSQL
>>>>>>
>>>>>
>>>>> If you get rid of the "Set adoRS.ActiveConnection ... " line, then
>>>>> you need to change this to
>>>>> adoRS.open strSQL,adoCN,,,adCmdText
>>>>>
>>>>> Otherwise, it should be:
>>>>> adoRS.open strSQL,,,,adCmdText
>>>>>
>>>>>> then further down the page I call a function GetRecords(). The
>>>>>> function looks like this:
>>>>>>
>>>>>> function GetRecords()
>>>>>> adoRS.movefirst
>>>>>> var1 = adoRS("field1")
>>>>>> ...........etc
>>>>>> end function
>>>>>
>>>>> Again, nothing sticks out. Is this function in the same script
>>>>> block? You haven't tried to use a server-side object in a
>>>>> client-side script block, have you?
>>>>>
>>>>> --
>>>>> Microsoft MVP -- ASP/ASP.NET
>>>>> Please reply to the newsgroup. The email account listed in my From
>>>>> header is my spam trap, so I don't check it very often. You will
>>>>> get a quicker response by posting to the newsgroup.
>>
>> --
>> Microsoft MVP -- ASP/ASP.NET
>> Please reply to the newsgroup. The email account listed in my From
>> header is my spam trap, so I don't check it very often. You will get
>> a quicker response by posting to the newsgroup.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.



Re: Use a recordset inside a Function? by David

David
Wed Jun 23 17:47:05 CDT 2004

Bob, I'll have to cut it down to post it. It's a huge page. I'll try and
post it tomorrow when I get back to work. Thanks for the help.


"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:eB3WwmWWEHA.2844@TK2MSFTNGP09.phx.gbl...
> Well, I'm stumped. Is there any chance of posting an abbreviated version
of
> your page in which this error can be reproduced? Use the Northwind sample
> database so we don't have to worry about getting sample data from you.
>
> Bob Barrows
>
> David Berry wrote:
> > Hi Bob. I just tried both those and I still get object required 'pRS'
> >
> >
> >
> > "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> > news:er4lp7VWEHA.3476@tk2msftngp13.phx.gbl...
> >> 1. Try declaring the function higher up on the page.
> >> 2. Try passing the recordset to the function instead of using the
> >> global variable. I.E.,
> >>
> >> adoRs.open ...
> >> ...
> >> GetRecords(adoRS)
> >>
> >>
> >> Function GetRecords(pRS)
> >> if not pRS.BOF then pRS.MoveFirst
> >> 'etc.
> >> End Function
> >>
> >>
> >>
> >> David Berry wrote:
> >>> PS - there's no client side code or script block on the page
> >>>
> >>>
> >>>
> >>> "David Berry" <dberry@mvps.org> wrote in message
> >>> news:euw2cwVWEHA.808@tk2msftngp13.phx.gbl...
> >>>> Hi Bob. The line that generates the error is adoRS.movefirst
> >>>> however if I remove that, ANY line that references the recordset
> >>>> generates the error. For example: var1= adoRS("Field1") would
> >>>> generate the error.
> >>>>
> >>>> function GetRecords()
> >>>> ---->>> adoRS.movefirst
> >>>> var1 = adoRS("field1")
> >>>> ...........etc
> >>>> end function
> >>>>
> >>>> Code that creates the recordset is in a script block at the top of
> >>>> the page and the function is in a script block about half way down
> >>>> the page. I'm calling the function near the end of the page.
> >>>> Getting rid of the Set adoRS.ActiveConnection line and changing it
> >>>> has no effect.
> >>>>
> >>>>
> >>>> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> >>>> news:uP1KlrVWEHA.2340@TK2MSFTNGP09.phx.gbl...
> >>>>> [Please don't post in HTML]
> >>>>>
> >>>>> I don't see anything wrong. Perhaps if you showed us which line
> >>>>> generates the error ...
> >>>>>
> >>>>> I do have some suggestions which I will put inline
> >>>>>
> >>>>> Bob Barrows
> >>>>>
> >>>>> "David Berry" <dberry@mvps.org> wrote in message
> >>>>> news:ufZZ4SVWEHA.556@tk2msftngp13.phx.gbl...
> >>>>>> I'm trying to use a recordset inside of a function but I'm
> >>>>>> getting an
> >>>>> "object required 'adoRS" error.
> >>>>>>
> >>>>>> At the top of the page I create my recordset, ex:
> >>>>>>
> >>>>>> dim strConnection, adoCN, adoRS, strSQL
> >>>>>>
> >>>>>> strConnection = <Connection>
> >>>>>> Set adoCN = server.CreateObject("ADODB.connection")
> >>>>>> Set adoRS = server.CreateObject("ADODB.recordset")
> >>>>>> adoCN.Open strConnection
> >>>>>> adoRS.ActiveConnection = adoCN
> >>>>>
> >>>>> This line is unnecessary. If forced to use it, it should be as
> >>>>> follows Set adoRS.ActiveConnection = adoCN
> >>>>>
> >>>>>>
> >>>>>> adoRS.CursorLocation = adUseClient
> >>>>>>
> >>>>>> strSQL = "S