Results 1 to 6 of 6

Thread: [RESOLVED] Referring Data Control from Outside the Form

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    11

    Resolved [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.

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    11

    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.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    11

    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.

  6. #6

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    11

    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
  •  



Click Here to Expand Forum to Full Width