Results 1 to 3 of 3

Thread: Modules

  1. #1
    Join Date
    May 2002
    Posts
    19

    Unanswered: Modules

    I am wanting to move all of my support code from my form to a module. However, I seem to be having difficulty. When I try to do this, I seem to not be getting all of my references formy controls on my form. For instance, I have a listbox. I lose my reference for ITEMSELECTED. What am I doing wrong?

    Thanks

  2. #2
    Join Date
    Jul 2002
    Location
    Romania
    Posts
    122
    The form 'knows' its elements. For instance, all following statements are correctly executed from within a form that has a text box control named MyControl:

    MyControl = 0
    Me("MyControl")=0
    Forms("FormName")("MyControl")=0

    If you move the code to a module, statement 1 will tell you that the variable has not been defined, statement 2 will generate a compile error (Me keyword is not accepted outside a form/report). It's only statement 3 that works, because you fully qualify the control you're referring to.

    Therefore, you have to declare and set the control within your module:
    Dim myctr as Control
    Set myctr = Forms("FormName")("ListBoxName")

    Now you should be able to work with ItemsSelected...

    Dan

  3. #3
    Join Date
    May 2002
    Posts
    19

    Thanks...You are the man

    By the way, the sql help from last week worked great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •