[AccessD] Using a dynamic recordset field.

Stuart McLachlan stuart at lexacorp.com.pg
Wed Aug 18 23:03:37 CDT 2010


or just rsDAO(strField)

On 18 Aug 2010 at 23:49, Michael Mattys wrote:

> Hi Darryl,
> 
> Just say rsDAO.Fields(strField) 
> 
> 
> Michael R Mattys
> Business Process Developers
> www.mattysconsulting.com
> 
> 
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Darryl
> Collins Sent: Wednesday, August 18, 2010 11:43 PM To: Access
> Developers discussion and problem solving Subject: [AccessD] Using a
> dynamic recordset field.
> 
> 
> ______________________________________________________________________
> ______ ___________
> 
> Note: This e-mail is subject to the disclaimer contained at the bottom
> of this message.
> ______________________________________________________________________
> ______ ___________
> 
> 
> Hi all,
> 
> I am hoping this is simple, but I cannot seem to get my head around
> the solution and it is rather tricky to google.
> 
> The problem is simple
> 
> I have a line in code like this
> 
> Dim strField as string
> 
> gstrSQL = "SELECT " & strField & " FROM tblWhatEver"
> Set rsDAO = DBEngine(0)(0).OpenRecordset(gstrSQL)
> 
> ' THIS WORKS:
> if rsDAO.Recordcount > 0 then
>  dblValue = rsDAO!AD
> end if
> 
> WHAT I WANT (and it doesn't work):
> if rsDAO.Recordcount > 0 then
>  dblValue = rsDAO!" & strField
> end if
> 
> Can I make the fieldname after the '!' dynamic?  and what is the
> syntax?
> 
> cheers
> Darryl.
> 
> 
> ______________________________________________________________________
> ______ ___________
> 
> The information transmitted in this message and its attachments (if
> any) is intended only for the person or entity to which it is
> addressed. The message may contain confidential and/or privileged
> material. Any review, retransmission, dissemination or other use of,
> or taking of any action in reliance upon this information, by persons
> or entities other than the intended recipient is prohibited.
> 
> If you have received this in error, please contact the sender and
> delete this e-mail and associated material from any computer.
> 
> The intended recipient of this e-mail may only use, reproduce,
> disclose or distribute the information contained in this e-mail and
> any attached files, with the permission of the sender.
> 
> This message has been scanned for viruses.
> ______________________________________________________________________
> ______ ___________
> 
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 





More information about the AccessD mailing list