• Subform.visible (but isnt?) (2000)

    Author
    Topic
    #420452

    I know, I know, quite a sudden barrage of problems, but until tonight, I’ve been leaving well enough alone, and working on some CCNA/CCNP classes. Tonight, since I’m all routered out, I switched my focus back to my database.

    My form has two subforms that alternate being hidden/visible. When my form is opened, my main subform shows just fine. My problem is that when I click the toggle button to hide subform 1 and display subform 2, subform 1 is hidden and subform 2 remains hidden….until I change the focus of my main form to another record. shrug

    Viewing 0 reply threads
    Author
    Replies
    • #952119

      Can you post the code you’re using (or a stripped down copy of the database)?

      • #952122

        Hans,
        I believe I may have overly-normalized my database, as all separate information groups are stored in separate tables, and each subform relates to only one table. Posting a stripped down copy requires some work. Hopefully this will help: The code segment is on my toggle button that *should* show my second form. Like I said before, the subform is visible after I change the focus to another record, so I’m not sure what’s causing the error. All subforms are (by default) set to Visible = No, except sfrmS1 (my main form).

        _________________________________________
        Private Sub tglBasicInfo_Click()
        If tglBasicInfo = True Then
        tglPersonalInfo = False
        tglAddressInfo = False
        tglShowS1 = False
        tglTrain = False
        tglMCI = False
        tglPromo = False
        sfrmProCon.Visible = False
        sfrmCompositeScore.Visible = False
        sfrmTraining.Visible = False
        sfrmS1.Visible = False
        sfrmAddresses.Visible = False
        sfrmPersonalInfo.Visible = False
        sfrmBasicInfo.Visible = True
        sfrmMCI.Visible = False
        Else
        sfrmBasicInfo.Visible = False
        End If
        End Sub
        ______________________________

        • #952124

          Hard to say without seeing the database, but perhaps you should set
          sfrmBasicInfo.Visible = True
          before hiding all the others.

          • #952126

            No dice. How do I set the focus of the form on the first record in my listbox on that form? Maybe that’ll alleviate the problem…I realize that Me!lstNames.SetFocus will set the focus on the list box, but how do I select the first record?

            • #952127

              Do you mean that you want to select the first item in the list box?

              Me.lstNames.Selected(0) = True

            • #952128

              Jeremy,

              DoCmd.GoToRecord , , acFirst

              Try adding this on the event to go to the first record based on the form its self. Also you could try to do a Me.Refresh after setting the visibility to true.

              If you mean selecting the first choice in the list box then use
              Me.lstNames.Selected(0) = True

              Winston

            • #952129

              Winston,
              hello! Thanks for the advice. I tried:
              DoCmd.GoToRecord , , acFirst

              However, still, no dice. If I use

              Me!List53.Selected(1) = True

              it works swimmingly. I think it may have something to do with the control source of the main form.

        • #952135

          From the look of this you have a number of subforms, and you are showing/hiding them with some toggle buttons.

          Why not just use a tabbed control with each subform on a separate page. It achieves the same result without you having to do any coding yourself.

          If all you want to do is show/hide subforms, why do you want to set the focus back to a list box, and to a particular item in the list box? Isn’t this going to switch you to a different record?

        • #952221

          Jeremy

          Tab Controls could be an option!

          Maybe it would be an idea to review your code, I can see it can get a bit confusing.

          Have you thought about using:

          If expression Then

          statements

          ElseIf expression-n Then

          elseifstatements

          Else

          elsestatements

          End If

          It will give you the opportunity to then put each item that you want to hide/unhide and set focus into smaller partitions and help with the logic. My 2cents worth

          • #952294

            Hi again, just checking the boards for my own answers and seen your post…hope all is well with you.

            I agree with the TABs for subforms…does make it easier. Look on your Toolbox toolbar for the TAB control button and then click your form, wherever you wish. What I don’t know is if there is a limit to the pages, but I’ve never heard of any.

            Nannette Padgett

            • #952296

              If there is a theoretical limit to the number of tabbed pages, it is much higher than the practical limit: a form can contain no more than 754 controls during its entire lifetime, so if you created a tab control with 1,000 pages (which is possible), you wouldn’t be able to populate all of them! grin

            • #952319

              When I originally designed this form, I had planned to use tabs. However, when trying to create them, I got an error, and wasn’t in the position to try to reinstall any or all of access. I am redesigning this form now, (I just received my personal laptop, with Office XP installed), and hopefully things will go better this time around. Most of the hard stuff is done (the designing of the subforms, coding the filter boxes, etc) so it shouldn’t take long. Thanks for all your help.

              Nannette, I hope all is well back in the states – – are you still teaching at CCCC? grin

    Viewing 0 reply threads
    Reply To: Subform.visible (but isnt?) (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: