Previous Thread

8/7/2006 4:49:02 AM    Retrieving data from a changing field using ADO
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



8/7/2006 1:05:24 PM    Re: Retrieving data from a changing field using ADO
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@discussions.microsoft.com> wrote in message 
 
news:CC250889-9D6C-4966-93B7-FD39F8BFB880@microsoft.com...