[AccessD] Using a dynamic recordset field.

Michael Mattys michael at mattysconsulting.com
Wed Aug 18 22:49:01 CDT 2010


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




More information about the AccessD mailing list