Results 1 to 5 of 5

Thread: VBA Referencing Variables from Form

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2002
    Posts
    11

    VBA Referencing Variables from Form

    Hey all, just have a quick problem.

    I'm working on an Access form that has a subform. I need the subform to pull some information from another database table, but in order to do that, I need to make some dynamic query statements, using variables from the main form. I'm unsure how this can be done. There are plenty of sites online that explain how to get variables from the subform to the main form, but I haven't found any that are vice versa.

    Can anyone give me an example? Thanks in advance!

  2. #2
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    should be as easy as this:

    Me.txtOne = [Forms]![myMainForm].txtTwo

    This takes data from textbox "txtTwo" on the main form "myMainForm" and puts it in the "txtOne" textbox on you subform....

  3. #3
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    You'll be lucky gaffer

    Subforms are nightmares... avoid them and use a listbox instead (personal view)


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  4. #4
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    Reference to the subform has always been a nightmare, but a reference to the main form is pretty easy I thought: I tested my theory out before I posted ...

  5. #5
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    Yup true.

    I'll read more carefully in the future

    You can also use Forms("formname").Controls("Controlname") but not when using instances...


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

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