Results 1 to 3 of 3

Thread: Set Focus (A2k)

  1. #1
    3 Star Lounger
    Join Date
    May 2003
    Location
    Sacramento, California, USA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Set Focus (A2k)

    <img src=/S/igiveup.gif border=0 alt=igiveup width=31 height=23> I've been struggling with this for hours and I know the answer is staring me in the face, but I cant see it!

    I have a main form with 2 subforms. I have 2 command buttons on the main form. The visible properties of the subforms is set to no. When I click on the command button to open the form, it becomes visible-no problem. On the subform I have a cmdCloseWindow. I need code for the Click event of this button to set visible back to false.

    If I put sbfStudentClasses.Visible = False , I get the compile error Variable not defined with sbfStudentClasses highlighted in the background. I've tried everything I can think of and can't make it work.

    I'm just begging to feel like a big dope, so please tell me the answer to this riddle!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Set Focus (A2k)

    If you have a command button on the subform that is intended to hide that subform, you have two problems:

    1. Since the command button is on the subform itself, you can't just make it invisible, you would have to set the focus to something on the main form first. It would be easier to put the command button on the main form. This would solve the next problem too.

    2. Since the command button is on the subform itself, you can't refer to the subform as sbfStudentClasses - VBA thinks that you refer to a subform of the subform. You'd have to use Me.Visible = False instead, but see above.

  3. #3
    3 Star Lounger
    Join Date
    May 2003
    Location
    Sacramento, California, USA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set Focus (A2k)

    Well, I guess I'm not a dope after all--At least there wasn't an obvious answer staring me in the face.

    Thanks once again Hans, I learn something new from you everyday!

Posting Permissions

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