[AccessD] Using a dynamic recordset field.

Darryl Collins Darryl.Collins at iag.com.au
Wed Aug 18 22:59:43 CDT 2010


_______________________________________________________________________________________

Note: This e-mail is subject to the disclaimer contained at the bottom of this message.
_______________________________________________________________________________________



Hi Michael,

aaah, In true AccessD style, I found the answer about 23.4 seconds after posting this enquiry. ;)
Thanks for your speedy reply though.
I ended up using

If rsDAO.RecordCount > 0 Then
    GetMainDataSit = rsDAO(strRisk)
End If

as part of the function. Works as expected.

Cheers
Darryl. 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Michael Mattys
Sent: Thursday, 19 August 2010 1:49 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Using a dynamic recordset field.

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
_______________________________________________________________________________________

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.
_______________________________________________________________________________________




More information about the AccessD mailing list