Why can't the data source property of a text box be changed at run time?
Are there any third party text boxes which allow this?
I need to be able to retreive the DataSource property of a
Database bound control so that I can read other properties
about the data field of that control so that I can validate
the data in that control.
Public Function Validate_Data_Control(Source_Control As Control) As Boolean
Dim Required As Boolean, Can_Be_Null As Boolean
Dim Parent_Data_Control As Control
' Get Properties about Database Field this control is Bound to
Parent_Data_Control = Source_Control.DataSource
Field_Name = Source_Control.DataField
Field_Type = Parent_Data_Control.Recordset(Field_Name).Type
Required = Parent_Data_Control.Recordset(Field_Name).Required
Can_Be_Null = Parent_Data_Control.Recordset(Field_Name).AllowZeroLength
The above code sample will not work because the Datasource
property cannot be retreived.
I would expect "Parent_Data_Control" to Hold the Data
control for the Database bound control but it has the
value of "Object Variable not set" as it should
since the help topic for DataSource states it is
unavailable at Run-Time.
I can get the Datafield property which tells me which
field the control refers to but I need the DataSource
property which would return me the Data Control which
would have DatabaseName property to tell me the location
of the database and the RecordSource Property.
I could pass these as extra parameters but then I have
to change code (The Parameters) along with changing the
properties of the control when the field the control is
bound to changes.
I need an indirect way to retreive this property.
If anyone could help I would greatly appreciate it.