Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Brugge, Belgium
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening hidden forms (MS ACCESS 2007)

    In my multiuser database, in order to get the things done as fast as possible, during the execution of the autoexec procedure i open all forms as "acNormal " and "hidden".
    e.g. "DoCmd.OpenForm "frmClients, acNormal , , ,, acHidden"
    When one of this forms is needed e.g. "frmClients", on my switchboard i click the appropriate button to fire the neccesary procedure. Because the form is already open and hidden,
    I believe that for displaying the form, it would be sufficient to use the code : Forms!frmClients.visible = True.
    Instead of this I use the command: " DoCmd.Openform "frmClients".
    The reason why I use this command is because the form must be capable to display Current Clients as well as Ex-Clients separately,
    and the command DoCmd.openform makes this possible by mean of the parameter "Filter"
    Although the forms is already open , it reacts on the command DoCmd.openform and works fine !!
    How does it comes that the form still reacts on this command?
    Futhermore,to inform the user what kind of clients the form displays, i like to have a title in the formheader of the form
    that displays the text "Current clients" or the text "Ex-Clients", depending on what kind of Clients the forms displays.
    Also, some command buttons on the form has to be disabled when the form is used to display ex-Clients e.g. CmdNew
    In order to make that possible, in the same DoCmd.Openform command , I have a tag with the text "Current" for displaying current clients, and the text "Ex" for displaying ex-clients.
    In the event "On Open" of the form "frmClients" i have the code;
    If me.tag = "current" then
    me!txtTitle.text = "Current Client"
    else
    me!!txtTitle.Text = "Ex-Client""
    me!cmdNew.disabled = true
    End If

    Although the form reacts on the command DoCmd.Openform even when the form is already open, the event "On Open" of the form doesn't fire
    and the code in this event will not be executed.
    Is it possible, when a form is made open and hidden during the setup of the program, to have code that can change the recordsource of
    the form, so that it can display different things, and to make that some text be change and some buttons disabled depending on the function of the form?

  2. #2
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening hidden forms (MS ACCESS 2007)

    I think you need to use the Form_Activate event to run your code. This event fires when a form receives the focus/is unhidden etc.. It fires after the Form_Open event when you open a form as well.
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  3. #3
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Brugge, Belgium
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening hidden forms (MS ACCESS 2007)

    I like to thank you for the advice, it's worth trying.
    Greetings from Belgium

  4. #4
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Brugge, Belgium
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening hidden forms (MS ACCESS 2007)

    The problem isn't solved. The event "On Activate "doesn't take place every time.
    When the program starts firing the autoexec procedure, the form frmClient as well as o lot other forms, is opened and hidden. Here the "on Activate" event taks place.
    When i want to use the form for the first time for displaying the current clients, the form has to be made visible ( not necessary to open the form, because the form is already open ) .
    Suppose now, after browsing in the form ,the form is made hidden again. ( not closing the form !).
    If now i try to use the same form again, but now for displaying the ex-clients, the form is made visible again, but this time the "on Activate" doens't take place !

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

    Re: Opening hidden forms (MS ACCESS 2007)

    Have you set the Popup property of the form to Yes? The Activate event doesn't occur for popup forms.

    When I unhide a form with Popup = No, the Activate event occurs each time. This is in Access 2002, admittedly, I don't have Access 2007 so I cannot test there.

  6. #6
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Brugge, Belgium
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening hidden forms (MS ACCESS 2007)

    Thank you very much for the tip. I'll check the setting of the form and I'll give it a try.

Posting Permissions

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