priya_pbk
asked on
ActiveX control and Datasource, ie bind my activeX ctrl to ADO control
Hi,
I am learning how to make an ActiveX controls.
I have been creating my own 'CoolTextBox' with properties properties like 'ChooseType'(which takes Numbers, letters or both) and 'ChooseCase'(which takes upppercase, lower case or both) etc. These works just fine.
I went a step further, and wanted my 'CooltextBox' to be bound to my ADO control in my Vbapplication.
Thru the ActiveX control Interface wizard, i mapped the Datasource property with datasource property of the text1. I also wanted to bind the Datafield property, but did'nt find it in the available properties.
I guess, the DataSource and the DataField are the 2 properties one needs to have, so that it can be bound to the ADO control in the Vb Application which would be using the cooltextbox control.
But it gives the follwoing error:
"User-defined datatype not defined" at the Datasource property.
Should i be giving any references. Where am i going wrong?
What are the different properties that i should bind to the text box in ActiveX control which will be simlar to any other textbox bound to the ADO control in my vb appln.
Priya
I am learning how to make an ActiveX controls.
I have been creating my own 'CoolTextBox' with properties properties like 'ChooseType'(which takes Numbers, letters or both) and 'ChooseCase'(which takes upppercase, lower case or both) etc. These works just fine.
I went a step further, and wanted my 'CooltextBox' to be bound to my ADO control in my Vbapplication.
Thru the ActiveX control Interface wizard, i mapped the Datasource property with datasource property of the text1. I also wanted to bind the Datafield property, but did'nt find it in the available properties.
I guess, the DataSource and the DataField are the 2 properties one needs to have, so that it can be bound to the ADO control in the Vb Application which would be using the cooltextbox control.
But it gives the follwoing error:
"User-defined datatype not defined" at the Datasource property.
Should i be giving any references. Where am i going wrong?
What are the different properties that i should bind to the text box in ActiveX control which will be simlar to any other textbox bound to the ADO control in my vb appln.
Priya
ASKER
sorry hiranmaya...for not accepting the proposed answer.
As i said, i could not locate the DataField property in the ActiveX InterFace Wizard.
My usercontrol design contains only a text box. Now should i add a adodc control to it also.
My requirement is simple:
-To start off, i want a text box which will accept,numbers or letter(uppercase, lower case or both) which i did
- Now I want this userControl to have the other properties that a normal text box have, like the Datasource, DataField and other necessary properties, so that I can bind these properties to the ADODB control in my VB appln which uses my ocx control in the form.
My issues are:
1)when i mapped the Datasouce to the Datasouce of the Text1..it gives me the following error:
"User-defined data type not defined"
2) and I did'nt find the DataField property in the available properties thru ActiveX Interface Wizard.
I hope this is not confusing.
As i said, i could not locate the DataField property in the ActiveX InterFace Wizard.
My usercontrol design contains only a text box. Now should i add a adodc control to it also.
My requirement is simple:
-To start off, i want a text box which will accept,numbers or letter(uppercase, lower case or both) which i did
- Now I want this userControl to have the other properties that a normal text box have, like the Datasource, DataField and other necessary properties, so that I can bind these properties to the ADODB control in my VB appln which uses my ocx control in the form.
My issues are:
1)when i mapped the Datasouce to the Datasouce of the Text1..it gives me the following error:
"User-defined data type not defined"
2) and I did'nt find the DataField property in the available properties thru ActiveX Interface Wizard.
I hope this is not confusing.
1.Pls set the let and get property in the activeX control before you compile ...
2. Use the control in the new project.
UserControl1.MyDatasource = ADODC1
Below is the set and let property for Database connection
Public Property Get MyDataSource() As ADODB.Connection
Set MyDataSource = Text1.DataSource
End Property
Public Property Let MyDataSource(ByVal New_MyDataSource As ADODB.Connection)
Set Text1.DataSource = New_MyDataSource
PropertyChanged "MyDataSource"
End Property
Private Sub UserControl_ReadProperties (PropBag As PropertyBag)
Set Text1.DataSource = PropBag.ReadProperty("MyDa taSource")
End Sub
Private Sub UserControl_WritePropertie s(PropBag As PropertyBag)
Call PropBag.WriteProperty("MyD ataSource" , Text1.DataSource)
End Sub
2. Use the control in the new project.
UserControl1.MyDatasource = ADODC1
Below is the set and let property for Database connection
Public Property Get MyDataSource() As ADODB.Connection
Set MyDataSource = Text1.DataSource
End Property
Public Property Let MyDataSource(ByVal New_MyDataSource As ADODB.Connection)
Set Text1.DataSource = New_MyDataSource
PropertyChanged "MyDataSource"
End Property
Private Sub UserControl_ReadProperties
Set Text1.DataSource = PropBag.ReadProperty("MyDa
End Sub
Private Sub UserControl_WritePropertie
Call PropBag.WriteProperty("MyD
End Sub
ASKER
sorry again!!
i am getting the following error :
"Data value named 'MyDataSource' not found"
at the usercontrol_read() properties
ie at the line :
Set Text1.DataSource = PropBag.ReadProperty("MyDa taSource")
Now how do i fix this:
also how will my text box come to know the following:
1)Datasource (will bind to adodc1 or adodc2 ..whatever..that's what we are trying to do..)
2)Datafield ..which coln will be bound to the text box in my vbproject..should'nt i be having another let and get property for the datafield property like MyDataField property?
Should i be declaring any variables or give reference to any application. I have given reference to Microsoft ActiveX DataObjects 2.6 Library.
I have'nt complied the code..but just testing by the form in the ocx project. It shows the error when I am running it.
As I said, since i am new to the making of ActiveX, therefore so many qts..
i hope you can help me with this!
priya
i am getting the following error :
"Data value named 'MyDataSource' not found"
at the usercontrol_read() properties
ie at the line :
Set Text1.DataSource = PropBag.ReadProperty("MyDa
Now how do i fix this:
also how will my text box come to know the following:
1)Datasource (will bind to adodc1 or adodc2 ..whatever..that's what we are trying to do..)
2)Datafield ..which coln will be bound to the text box in my vbproject..should'nt i be having another let and get property for the datafield property like MyDataField property?
Should i be declaring any variables or give reference to any application. I have given reference to Microsoft ActiveX DataObjects 2.6 Library.
I have'nt complied the code..but just testing by the form in the ocx project. It shows the error when I am running it.
As I said, since i am new to the making of ActiveX, therefore so many qts..
i hope you can help me with this!
priya
But you have to define let and get property anyhow that i can say! Goodluck.
Set for ref: Microsoft Datasource Interfaces and compile.
'************************* ********** ********** **********
'Default Property Values:
Const m_def_mydatasource = 0
'Property Variables:
Dim m_DataMembers As DataMembers
Dim m_mydatasource As Variant
Public Property Get DataMember() As String
DataMember = Text1.DataMember
End Property
Public Property Let DataMember(ByVal New_DataMember As String)
Text1.DataMember() = New_DataMember
PropertyChanged "DataMember"
End Property
Public Property Get DataMembers() As DataMembers
Set DataMembers = m_DataMembers
End Property
Public Property Set DataMembers(ByVal New_DataMembers As DataMembers)
Set m_DataMembers = New_DataMembers
PropertyChanged "DataMembers"
End Property
Public Property Get DataSource() As DataSource
Set DataSource = Text1.DataSource
End Property
Public Property Set DataSource(ByVal New_DataSource As DataSource)
Set Text1.DataSource = New_DataSource
PropertyChanged "DataSource"
End Property
Public Property Get mydatasource() As Variant
mydatasource = m_mydatasource
End Property
Public Property Let mydatasource(ByVal New_mydatasource As Variant)
m_mydatasource = New_mydatasource
PropertyChanged "mydatasource"
End Property
'Initialize Properties for User Control
Private Sub UserControl_InitProperties ()
m_mydatasource = m_def_mydatasource
End Sub
'Load property values from storage
Private Sub UserControl_ReadProperties (PropBag As PropertyBag)
Set DataFormat = PropBag.ReadProperty("Data Format", Nothing)
Text1.DataMember = PropBag.ReadProperty("Data Member", "")
Set m_DataMembers = PropBag.ReadProperty("Data Members", Nothing)
Set DataSource = PropBag.ReadProperty("Data Source", Nothing)
m_mydatasource = PropBag.ReadProperty("myda tasource", m_def_mydatasource)
End Sub
'Write property values to storage
Private Sub UserControl_WritePropertie s(PropBag As PropertyBag)
Call PropBag.WriteProperty("Dat aFormat", DataFormat, Nothing)
Call PropBag.WriteProperty("Dat aMember", Text1.DataMember, "")
Call PropBag.WriteProperty("Dat aMembers", m_DataMembers, Nothing)
Call PropBag.WriteProperty("Dat aSource", DataSource, Nothing)
Call PropBag.WriteProperty("myd atasource" , m_mydatasource, m_def_mydatasource)
End Sub
'************************* ********** ********** *********
And in a new project, add the user control
and for example try for ADODC connection referecene:
Set UserControl11.DataSource = Adodc1
'*************************
'Default Property Values:
Const m_def_mydatasource = 0
'Property Variables:
Dim m_DataMembers As DataMembers
Dim m_mydatasource As Variant
Public Property Get DataMember() As String
DataMember = Text1.DataMember
End Property
Public Property Let DataMember(ByVal New_DataMember As String)
Text1.DataMember() = New_DataMember
PropertyChanged "DataMember"
End Property
Public Property Get DataMembers() As DataMembers
Set DataMembers = m_DataMembers
End Property
Public Property Set DataMembers(ByVal New_DataMembers As DataMembers)
Set m_DataMembers = New_DataMembers
PropertyChanged "DataMembers"
End Property
Public Property Get DataSource() As DataSource
Set DataSource = Text1.DataSource
End Property
Public Property Set DataSource(ByVal New_DataSource As DataSource)
Set Text1.DataSource = New_DataSource
PropertyChanged "DataSource"
End Property
Public Property Get mydatasource() As Variant
mydatasource = m_mydatasource
End Property
Public Property Let mydatasource(ByVal New_mydatasource As Variant)
m_mydatasource = New_mydatasource
PropertyChanged "mydatasource"
End Property
'Initialize Properties for User Control
Private Sub UserControl_InitProperties
m_mydatasource = m_def_mydatasource
End Sub
'Load property values from storage
Private Sub UserControl_ReadProperties
Set DataFormat = PropBag.ReadProperty("Data
Text1.DataMember = PropBag.ReadProperty("Data
Set m_DataMembers = PropBag.ReadProperty("Data
Set DataSource = PropBag.ReadProperty("Data
m_mydatasource = PropBag.ReadProperty("myda
End Sub
'Write property values to storage
Private Sub UserControl_WritePropertie
Call PropBag.WriteProperty("Dat
Call PropBag.WriteProperty("Dat
Call PropBag.WriteProperty("Dat
Call PropBag.WriteProperty("Dat
Call PropBag.WriteProperty("myd
End Sub
'*************************
And in a new project, add the user control
and for example try for ADODC connection referecene:
Set UserControl11.DataSource = Adodc1
ASKER
i did define the let and get property for MyDataSource and also the changes in read and write properties.I wrote exactly as you had said..still it gives me the 'Runtime error' ie
"Data value named 'MyDataSource' not found"
Any workaround??
"Data value named 'MyDataSource' not found"
Any workaround??
ASKER
ok. thru with one of the step. I was able to bind my SuperTextbox with ADODC in my VB appln. The problem becoz I was not giving any reference to Microsoft DataSources Interface(which i did'nt know)
But still, there is a problem/issues.
1) How do i bind my superTextBox with one of the column of the Adodc control(say companyName of the Company Table). I started writing the let and get property for DataField, simlar to the Datamember property. I did this and my application crashed thrice. Any more refrences to be given.
2)Also i wanted to know, when we could accomplish binding the Adodc control thru the let and get property of Datasource, why do we have a second property viz, mydatasource with a default value=0. What does this do?
3)why do we have a DataMember(let and get)property and again a DataMembers(let and get) property. how does this thing work. As far as i know, the Datasource and DataMember are 2 properties which works in conjuction with each other and again why 2 let and get properties for datamember and dataMembers(not seen at design time in the properties window)
Thanks a lot and hope u can help..priya
But still, there is a problem/issues.
1) How do i bind my superTextBox with one of the column of the Adodc control(say companyName of the Company Table). I started writing the let and get property for DataField, simlar to the Datamember property. I did this and my application crashed thrice. Any more refrences to be given.
2)Also i wanted to know, when we could accomplish binding the Adodc control thru the let and get property of Datasource, why do we have a second property viz, mydatasource with a default value=0. What does this do?
3)why do we have a DataMember(let and get)property and again a DataMembers(let and get) property. how does this thing work. As far as i know, the Datasource and DataMember are 2 properties which works in conjuction with each other and again why 2 let and get properties for datamember and dataMembers(not seen at design time in the properties window)
Thanks a lot and hope u can help..priya
ASKER
are you suggesting the same answer..ie 05/06/2002 06:39AM PST or is this some bug in displaying..This is not clear.!
ASKER
Will I ever finish making my ActiveX Control!
ASKER
Update:
This is how my code looks now in the Usercontrol Code:
-------------------------- ---------- ---------- ----------
'Set for ref: Microsoft Datasource Interfaces and compile.
'************************* ********** ********** **********
'Default Property Values:
Const m_def_mydatasource = 0
'Property Variables:
Dim m_DataMembers As DataMembers
Dim m_mydatasource As Variant
Private Sub UserControl_Resize()
With Text1
.Height = UserControl.ScaleHeight
.Top = UserControl.ScaleTop
.Width = UserControl.ScaleWidth
.Left = UserControl.ScaleLeft
End With
End Sub
Public Property Get DataMember() As String
DataMember = Text1.DataMember
End Property
Public Property Let DataMember(ByVal New_DataMember As String)
Text1.DataMember() = New_DataMember
PropertyChanged "DataMember"
End Property
Public Property Get DataMembers() As DataMembers
Set DataMembers = m_DataMembers
End Property
Public Property Set DataMembers(ByVal New_DataMembers As DataMembers)
Set m_DataMembers = New_DataMembers
PropertyChanged "DataMembers"
End Property
Public Property Get DataSource() As DataSource
Set DataSource = Text1.DataSource
End Property
Public Property Set DataSource(ByVal New_DataSource As DataSource)
Set Text1.DataSource = New_DataSource
PropertyChanged "DataSource"
End Property
'Initialize Properties for User Control
Private Sub UserControl_InitProperties ()
m_mydatasource = m_def_mydatasource
End Sub
'Load property values from storage
Private Sub UserControl_ReadProperties (PropBag As PropertyBag)
Set DataFormat = PropBag.ReadProperty("Data Format", Nothing)
Text1.DataMember = PropBag.ReadProperty("Data Member", "")
Set m_DataMembers = PropBag.ReadProperty("Data Members", Nothing)
Set DataSource = PropBag.ReadProperty("Data Source", Nothing)
' m_mydatasource = PropBag.ReadProperty("myda tasource", m_def_mydatasource)
End Sub
'Write property values to storage
Private Sub UserControl_WritePropertie s(PropBag As PropertyBag)
Call PropBag.WriteProperty("Dat aFormat", DataFormat, Nothing)
Call PropBag.WriteProperty("Dat aMember", Text1.DataMember, "")
Call PropBag.WriteProperty("Dat aMembers", m_DataMembers, Nothing)
Call PropBag.WriteProperty("Dat aSource", DataSource, Nothing)
'Call PropBag.WriteProperty("myd atasource" , m_mydatasource, m_def_mydatasource)
End Sub
'------------------------- ---------- ---------- ---------
'My VB application'..Standard Exe
I have my superTextbox in my form and an ADODC control in my form.
At design time I have set the following:
-I have bounded the Adodc1 with a Company Table.
-datasource of the SuperTextBox as Adodc1.
Now since I wanted the DataField property of the text box to be mapped to the SuperTextBox...I wrote the foll code in the usercontrol
-------------------------- ---------- -------
Public Property Get MyDataField() As String
MyDataField = Text1.DataField
End Property
Public Property Let MyDataField(ByVal New_MyDataField As String)
Text1.DataField() = New_MyDataField
PropertyChanged "MyDataField"
End Property
Private Sub UserControl_WritePropertie s(PropBag As PropertyBag)
Call PropBag.WriteProperty("MyD ataField", Text1.DataField, "")
End Sub
Private Sub UserControl_ReadProperties (PropBag As PropertyBag)
Text1.DataField = PropBag.ReadProperty("MyDa taField", "")
End Sub
-------------------------- ---------- ---------- ----------
This is what happened when i was trying to set the properties of the SuperControl at "DESIGN TIME"
-SuperControl.Datasource=A dodc1(fine ..no problem)
-SuperControl.MyDatafield= companyNam e( name of one of the col of company).
When I did this it showed me the first companyName of the table at DESIGN TIME, then when I executed the standard exe form, the application terminated giving me the vbexe error..that Memory could not be "read" thus crashing the application.
Where am I going wrong..hope you can help me to try to solve this and dont worry abt the points, I will surely double it.
Also I am still not clear with the DataMembers and Data Member details.
I hope you can help me..
priya
This is how my code looks now in the Usercontrol Code:
--------------------------
'Set for ref: Microsoft Datasource Interfaces and compile.
'*************************
'Default Property Values:
Const m_def_mydatasource = 0
'Property Variables:
Dim m_DataMembers As DataMembers
Dim m_mydatasource As Variant
Private Sub UserControl_Resize()
With Text1
.Height = UserControl.ScaleHeight
.Top = UserControl.ScaleTop
.Width = UserControl.ScaleWidth
.Left = UserControl.ScaleLeft
End With
End Sub
Public Property Get DataMember() As String
DataMember = Text1.DataMember
End Property
Public Property Let DataMember(ByVal New_DataMember As String)
Text1.DataMember() = New_DataMember
PropertyChanged "DataMember"
End Property
Public Property Get DataMembers() As DataMembers
Set DataMembers = m_DataMembers
End Property
Public Property Set DataMembers(ByVal New_DataMembers As DataMembers)
Set m_DataMembers = New_DataMembers
PropertyChanged "DataMembers"
End Property
Public Property Get DataSource() As DataSource
Set DataSource = Text1.DataSource
End Property
Public Property Set DataSource(ByVal New_DataSource As DataSource)
Set Text1.DataSource = New_DataSource
PropertyChanged "DataSource"
End Property
'Initialize Properties for User Control
Private Sub UserControl_InitProperties
m_mydatasource = m_def_mydatasource
End Sub
'Load property values from storage
Private Sub UserControl_ReadProperties
Set DataFormat = PropBag.ReadProperty("Data
Text1.DataMember = PropBag.ReadProperty("Data
Set m_DataMembers = PropBag.ReadProperty("Data
Set DataSource = PropBag.ReadProperty("Data
' m_mydatasource = PropBag.ReadProperty("myda
End Sub
'Write property values to storage
Private Sub UserControl_WritePropertie
Call PropBag.WriteProperty("Dat
Call PropBag.WriteProperty("Dat
Call PropBag.WriteProperty("Dat
Call PropBag.WriteProperty("Dat
'Call PropBag.WriteProperty("myd
End Sub
'-------------------------
'My VB application'..Standard Exe
I have my superTextbox in my form and an ADODC control in my form.
At design time I have set the following:
-I have bounded the Adodc1 with a Company Table.
-datasource of the SuperTextBox as Adodc1.
Now since I wanted the DataField property of the text box to be mapped to the SuperTextBox...I wrote the foll code in the usercontrol
--------------------------
Public Property Get MyDataField() As String
MyDataField = Text1.DataField
End Property
Public Property Let MyDataField(ByVal New_MyDataField As String)
Text1.DataField() = New_MyDataField
PropertyChanged "MyDataField"
End Property
Private Sub UserControl_WritePropertie
Call PropBag.WriteProperty("MyD
End Sub
Private Sub UserControl_ReadProperties
Text1.DataField = PropBag.ReadProperty("MyDa
End Sub
--------------------------
This is what happened when i was trying to set the properties of the SuperControl at "DESIGN TIME"
-SuperControl.Datasource=A
-SuperControl.MyDatafield=
When I did this it showed me the first companyName of the table at DESIGN TIME, then when I executed the standard exe form, the application terminated giving me the vbexe error..that Memory could not be "read" thus crashing the application.
Where am I going wrong..hope you can help me to try to solve this and dont worry abt the points, I will surely double it.
Also I am still not clear with the DataMembers and Data Member details.
I hope you can help me..
priya
Use activex control wizard in the VB6. Preject->Add User Control->VB ActiveX Control Interface Wizard. It will help you a lot.
You can add datafield property same as datamember or other prop to the user control and try now!
You can add datafield property same as datamember or other prop to the user control and try now!
ASKER
yes, I am using the ActiveX Interface Wizard. I did'nt want the default properties like font, backcolor etc..right now, coz i needed the above properties in the code first.
But the sad part is that I did'nt get this particular property i.e 'DataField' in the Wizard while mapping, but other properties like datasouce, datamembers, datamember, dataformat,drawmode, drawstyle, drawwidth and I dont see any 'dataField' property at all.
I also tried adding a new property "DataField" thru wizard..gives me a message " The member name you have created is already being used by the Extender object"
Since you say the DataField property is available at the time of mapping, but i dont seem to find it at all.
Is 'nt it supposed to show all the properties of the text box(constituent controls) while mapping!
But the sad part is that I did'nt get this particular property i.e 'DataField' in the Wizard while mapping, but other properties like datasouce, datamembers, datamember, dataformat,drawmode, drawstyle, drawwidth and I dont see any 'dataField' property at all.
I also tried adding a new property "DataField" thru wizard..gives me a message " The member name you have created is already being used by the Extender object"
Since you say the DataField property is available at the time of mapping, but i dont seem to find it at all.
Is 'nt it supposed to show all the properties of the text box(constituent controls) while mapping!
ASKER
ok, here's the update.
It seems this is a bug in Microsoft. Pls refer to this article:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q189924
so, was this a sheer waste..any one with a workaround for fixing this bug!
It seems this is a bug in Microsoft. Pls refer to this article:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q189924
so, was this a sheer waste..any one with a workaround for fixing this bug!
Hi pbk,
Try Now.
For User control:
Const m_def_mydatasource = 0
Dim m_DataMembers As DataMembers
Public Property Get DataField() As String
DataField = Text1.DataField
End Property
Public Property Let DataField(ByVal New_DataField As String)
Text1.DataField = New_DataField
PropertyChanged "DataField"
End Property
Public Property Get DataMember() As String
DataMember = Text1.DataMember
End Property
Public Property Let DataMember(ByVal New_DataMember As String)
Text1.DataMember() = New_DataMember
PropertyChanged "DataMember"
End Property
Public Property Get DataMembers() As DataMembers
Set DataMembers = m_DataMembers
End Property
Public Property Set DataMembers(ByVal New_DataMembers As DataMembers)
Set m_DataMembers = New_DataMembers
PropertyChanged "DataMembers"
End Property
Public Property Get DataSource() As DataSource
Set DataSource = Text1.DataSource
End Property
Public Property Set DataSource(ByVal New_DataSource As DataSource)
Set Text1.DataSource = New_DataSource
PropertyChanged "DataSource"
End Property
'Initialize Properties for User Control
Private Sub UserControl_InitProperties ()
m_mydatasource = m_def_mydatasource
End Sub
'Load property values from storage
Private Sub UserControl_ReadProperties (PropBag As PropertyBag)
Set DataFormat = PropBag.ReadProperty("Data Format", Nothing)
Text1.DataField = PropBag.ReadProperty("Data Field", "")
Text1.DataMember = PropBag.ReadProperty("Data Member", "")
Set m_DataMembers = PropBag.ReadProperty("Data Members", Nothing)
Set DataSource = PropBag.ReadProperty("Data Source", Nothing)
End Sub
'Write property values to storage
Private Sub UserControl_WritePropertie s(PropBag As PropertyBag)
Call PropBag.WriteProperty("Dat aFormat", DataFormat, Nothing)
Call PropBag.WriteProperty("Dat aField", Text1.DataField, "")
Call PropBag.WriteProperty("Dat aMember", Text1.DataMember, "")
Call PropBag.WriteProperty("Dat aMembers", m_DataMembers, Nothing)
Call PropBag.WriteProperty("Dat aSource", DataSource, Nothing)
End Sub
For New Exe project (for testing):
1. Add one ADODC
2. Add compiled user control
3. Add Text1
4. Bind ADODC connection with connection string, And record source
5. Bind datasource and datafield property of user control and text box for testing.
6.Everything navigates smoothly.
Try Now.
For User control:
Const m_def_mydatasource = 0
Dim m_DataMembers As DataMembers
Public Property Get DataField() As String
DataField = Text1.DataField
End Property
Public Property Let DataField(ByVal New_DataField As String)
Text1.DataField = New_DataField
PropertyChanged "DataField"
End Property
Public Property Get DataMember() As String
DataMember = Text1.DataMember
End Property
Public Property Let DataMember(ByVal New_DataMember As String)
Text1.DataMember() = New_DataMember
PropertyChanged "DataMember"
End Property
Public Property Get DataMembers() As DataMembers
Set DataMembers = m_DataMembers
End Property
Public Property Set DataMembers(ByVal New_DataMembers As DataMembers)
Set m_DataMembers = New_DataMembers
PropertyChanged "DataMembers"
End Property
Public Property Get DataSource() As DataSource
Set DataSource = Text1.DataSource
End Property
Public Property Set DataSource(ByVal New_DataSource As DataSource)
Set Text1.DataSource = New_DataSource
PropertyChanged "DataSource"
End Property
'Initialize Properties for User Control
Private Sub UserControl_InitProperties
m_mydatasource = m_def_mydatasource
End Sub
'Load property values from storage
Private Sub UserControl_ReadProperties
Set DataFormat = PropBag.ReadProperty("Data
Text1.DataField = PropBag.ReadProperty("Data
Text1.DataMember = PropBag.ReadProperty("Data
Set m_DataMembers = PropBag.ReadProperty("Data
Set DataSource = PropBag.ReadProperty("Data
End Sub
'Write property values to storage
Private Sub UserControl_WritePropertie
Call PropBag.WriteProperty("Dat
Call PropBag.WriteProperty("Dat
Call PropBag.WriteProperty("Dat
Call PropBag.WriteProperty("Dat
Call PropBag.WriteProperty("Dat
End Sub
For New Exe project (for testing):
1. Add one ADODC
2. Add compiled user control
3. Add Text1
4. Bind ADODC connection with connection string, And record source
5. Bind datasource and datafield property of user control and text box for testing.
6.Everything navigates smoothly.
Sorry forgot to tell. In the usercontrol, click tools->procedure attributes-> for data member click advance option and check property is data bound.
ASKER
hi hiranmaya,
i would really appreciate if you can try this code yourself, because I have been trying to do this since so long. Now I did exactly as you said. Exactly the same code. But gave me vb6.exe error. ie could not read the memory and the application crashed.
I also bound the dataField thru the procedure attributes. If you had noticed in the article i had mentioned as a link, in the DataField Get and let procedures it is not...
Text1.DataField=... (this procdure makes the vb appln crash)
but
Text1.Text=...
as i had said this happens to be bug with the some of the databound properties of Microsoft which is not fixed.
if you dont mind, I would appreciate if you can try this code by making this ocx.
i would really appreciate if you can try this code yourself, because I have been trying to do this since so long. Now I did exactly as you said. Exactly the same code. But gave me vb6.exe error. ie could not read the memory and the application crashed.
I also bound the dataField thru the procedure attributes. If you had noticed in the article i had mentioned as a link, in the DataField Get and let procedures it is not...
Text1.DataField=... (this procdure makes the vb appln crash)
but
Text1.Text=...
as i had said this happens to be bug with the some of the databound properties of Microsoft which is not fixed.
if you dont mind, I would appreciate if you can try this code by making this ocx.
I have tried and tested..I can navigate through data also. Sorry I can not help you more.
ASKER
ok..did the following changes and made it run for the first time with proper values.
changes are as follows:
Public Property Get DataField() As String
DataField = Text1.Text '(it was text1.datafield)
End Property
Public Property Let DataField(ByVal New_DataField As String)
'(this too was text1.datafield)
Text1.Text = New_DataField
PropertyChanged "DataField"
End Property
Also bound the datamember thru procedure attributes.
Runs fine for the first time, but as soon as one comes to design time, all the properties are gone. One needs to set it again, ie datasource and datafield etc.
It also seems when one compiles the code to make an exe, the properties are all gone. So Tough luck!
changes are as follows:
Public Property Get DataField() As String
DataField = Text1.Text '(it was text1.datafield)
End Property
Public Property Let DataField(ByVal New_DataField As String)
'(this too was text1.datafield)
Text1.Text = New_DataField
PropertyChanged "DataField"
End Property
Also bound the datamember thru procedure attributes.
Runs fine for the first time, but as soon as one comes to design time, all the properties are gone. One needs to set it again, ie datasource and datafield etc.
It also seems when one compiles the code to make an exe, the properties are all gone. So Tough luck!
When i did from myside with the new code and compiled the activex control, in the new project i can see the all datafield,datamember properties for that user control.
ASKER
Have you tried compiling the Vb project and make it an executable. Then try running the exe. Do you get to see the details in the ActiveX control text box.
ASKER
Thanks hiranmaya. I appreciate your effort to help me with this code. As I had mentioned earlier, I have increased the points to 100, as I had promised. Even though my code is still not in a workable condition, I sincerely thank you for your effort as I was able to gain some insight and knowledge in ActiveX controls--thanks,priya.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks hiranmaya. I appreciate your effort to help me with this code. As I had mentioned earlier, I have increased the points to 100, as I had promised. Even though my code is still not in a workable condition, I sincerely thank you for your effort as I was able to gain some insight and knowledge in ActiveX controls--thanks,priya.
ASKER
thanks. I hope you did too!
ASKER
thanks. I hope you did too!
Private Sub UserControl_Initialize()
'Assign Connection string
Adodc1.ConnectionString = "DSN=XYZ"
'Assign Recordsource
Adodc1.RecordSource = "ABC"
'Refresh Or Requery
Adodc1.Refresh
'already mapped the connection to text
'Map fields
Text1.DataField = "FIELD NAME"
End Sub