|
-
Sep 2nd, 2010, 03:06 PM
#1
Thread Starter
New Member
[RESOLVED] Referring Data Control from Outside the Form
Hi everyone
I'm trying to refer a data control in a form in which it is not actually placed. I have a main form, where all the data controls ( linking to the various tables) in the database are present.
1) Is it possible for me to bound textboxes and labels on other forms to these data controls on the main form.
2) is not using a different data control on every form going to improve performance or not.
Thanks everyone
PS I'm a beginner in VB.
-
Sep 2nd, 2010, 03:57 PM
#2
Re: Referring Data Control from Outside the Form
Welcome to Forums, feelit! 
I suppose you can reuse data control but... using ADODB library instead will give you much more flexibility and more control too.
For more information take a look at VB6 ADO Tutorials.
-
Sep 2nd, 2010, 04:54 PM
#3
Thread Starter
New Member
Re: Referring Data Control from Outside the Form
Can you be a bit more specific please , as in how i can reuse the data control or using the ADODB library. I tried to bind the textboxes, through both the properties and code, but it didn't work.
-
Sep 2nd, 2010, 06:25 PM
#4
Re: Referring Data Control from Outside the Form
If you must use a data control, try the ADO DataControl (ADODC). Add it to your toolbox if not already done (Ctrl+T).
Then you can dynamically set it during runtime at Form_Load
Code:
' form2
Text1.DataField = "" ' << only needed if a previous datasource was already assigned
Set Text1.DataSource = Form1.Adodc1
Text1.DataField = "Title"
Don't know if you can do this with the basic Data control (Data1)
Last edited by LaVolpe; Sep 7th, 2010 at 02:07 PM.
-
Sep 3rd, 2010, 06:38 AM
#5
Thread Starter
New Member
Re: Referring Data Control from Outside the Form
So the DataField property must be reset before a new DataSource is assigned. Thanks LaVolpe, didn't know that.
-
Sep 7th, 2010, 01:59 PM
#6
Thread Starter
New Member
Re: Referring Data Control from Outside the Form
You can't do that with a Data Control. It raises a type mismatch error. It can only be done with an ado control
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|