[AccessD] determining the datatype of a bound control

John W. Colby jwcolby at colbyconsulting.com
Wed Mar 24 14:51:20 CST 2004


I just got the "if it's a table" part.  That's not so nice since many forms
are bound to queries.

John W. Colby
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Charlotte
Foust
Sent: Wednesday, March 24, 2004 11:38 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] determining the datatype of a bound control


John,

This will do it if your form's recordsource is a table

    Dim strCtlSrc As String
    Dim strDataSrc As String
    Dim rst As ADODB.Recordset
    Dim intType As Integer

    strDataSrc = Me.RecordSource
    strCtlSrc = txtDOB.ControlSource
    Set rst = New ADODB.Recordset
    rst.Open strDataSrc , CurrentProject.Connection, , , adCmdTable

    intType = rst.Fields(strCtlSrc).Type

Assuming the underlying field is a date, this will return a 7, which is
adDate

Charlotte Foust

-----Original Message-----
From: John W. Colby [mailto:jwcolby at colbyconsulting.com]
Sent: Tuesday, March 23, 2004 12:08 PM
To: AccessD
Subject: [AccessD] determining the datatype of a bound control


I currently determine the data type of the data that a control is
displaying by the following code:

Dim strCtlSrc As String
Dim rst As DAO.Recordset
Dim intType As Integer
    strCtlSrc = txtDOB.ControlSource
    Set rst = Me.RecordsetClone
    intType = rst.Fields(strCtlSrc).Type

Is there a similar method of getting at this from ADO?

John W. Colby
www.ColbyConsulting.com


--
_______________________________________________
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