Group:  Microsoft Access ยป microsoft.public.access.modulesdaovba.ado
Thread: Retrieving data from a changing field using ADO

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Retrieving data from a changing field using ADO
rael_lucid 07.08.2006 11:49:02
Hi,
Subject is extremely vague, let me explain:

Have a table with the following fields:
ItemID (Pkey)
Price1
Price2
....
Price 10

I have some code which is used to retrieve a specific price for a specific
item. The price returned is dependent on user input. ie: The user will
request "Price1", or "Price7" etc

Is it possible in VBA to retrieve the requested field using code similar to
the following:

Function GetPrice(ItemID as long) as Double
....
rsTemp.Open "SELECT * FROM ItemPrices WHERE ItemID = " & {User Entered},
CurrentProject.Connection
....
GetPrice = rsTemp! & {String Variable} ******* THIS IS THE LINE
OF CONCERN
....
End Function

Hopefully that is enough info to advise. Let me know if you need more.

Thanks

Rael
Re: Retrieving data from a changing field using ADO
"Brendan Reynolds" <brenreyn[ at ]discussions.microsoft.com> 07.08.2006 12:05:24
The syntax would be ...

rst.Fields(StringVariableHere)

.... or, because Fields is the default property of the Recordset object, you
can use ...

rst(StringVariableHere)

--
Brendan Reynolds
Access MVP

"rael_lucid" <raellucid[ at ]discussions.microsoft.com> wrote in message
news:CC250889-9D6C-4966-93B7-FD39F8BFB880[ at ]microsoft.com...
[Quoted Text]
> Hi,
> Subject is extremely vague, let me explain:
>
> Have a table with the following fields:
> ItemID (Pkey)
> Price1
> Price2
> ...
> Price 10
>
> I have some code which is used to retrieve a specific price for a specific
> item. The price returned is dependent on user input. ie: The user will
> request "Price1", or "Price7" etc
>
> Is it possible in VBA to retrieve the requested field using code similar
> to
> the following:
>
> Function GetPrice(ItemID as long) as Double
> ...
> rsTemp.Open "SELECT * FROM ItemPrices WHERE ItemID = " & {User Entered},
> CurrentProject.Connection
> ...
> GetPrice = rsTemp! & {String Variable} ******* THIS IS THE LINE
> OF CONCERN
> ...
> End Function
>
> Hopefully that is enough info to advise. Let me know if you need more.
>
> Thanks
>
> Rael


Re: Retrieving data from a changing field using ADO
rael_lucid 07.08.2006 12:15:02
Thanks Brendan.
I have amended the code and will run some tests tomorrow with the data.

Rael

"Brendan Reynolds" wrote:

[Quoted Text]
> The syntax would be ...
>
> rst.Fields(StringVariableHere)
>
> .... or, because Fields is the default property of the Recordset object, you
> can use ...
>
> rst(StringVariableHere)
>
> --
> Brendan Reynolds
> Access MVP
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net