Results 1 to 14 of 14
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Littleton, Colorado, USA
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Generic 'CloseForm' (A2K/SR1)

    I have a form I'm calling from another. In this new form, call it " <font color=008080>frmUserInput</font color=008080> ," I want to continue to prompt the user for appropriate data. Once the user has entered the appropriate data, close that form and return focus to the original form, say " <font color=008080>frmOriginal</font color=008080> ." So far, no problem. However, should the user select to simply close <font color=008080>frmUserInput</font color=008080> , I'd like to be able to close <font color=008080>frmOriginal </font color=008080> with no further action. <font color=008080>frmOriginal </font color=008080> is set up as a popup form, not modal. When it calls <font color=008080>frmUserInput </font color=008080> (popup and modal), <font color=008080>frmOriginal </font color=008080> stays on top. If I change over to <font color=008080>frmUserInput</font color=008080> , I can do everything I want but close <font color=008080>frmOriginal</font color=008080> .

    I'd like several other forms to be able to call frmUserInput and be treated the same way. What I've done then, is to use DoCmd.OpenForm and pass " <font color=008080>frmOriginal</font color=008080> " as the OpenArgs variable. When I try to close <font color=008080>frmUserInput</font color=008080> , I try DoCmd.Close Me.OpenArgs, but it doesn't work. Further, since <font color=008080>frmUserInput </font color=008080> is being hid by <font color=008080>frmOriginal</font color=008080> , I am setting <font color=008080>frmOriginal</font color=008080> .Visible to False when calling <font color=008080>frmUserInput </font color=008080> to hide it so the User can see <font color=008080>frmUserInput</font color=008080> . When I close this form, I've tried Forms(Me.OpenArg).Visible = True, but get a type mismatch error.

    Any advise? Thanks in advance.

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

    Re: Generic 'CloseForm' (A2K/SR1)

    In my experience, a form sometimes "forgets" OpenArgs after a while. To work around this, define a module-level variable at the top of the form module of frmUserInput:

    Private strCaller As String

    Set the value of strCaller in the On Load event:

    Private Sub Form_Load()
    strCaller = Nz(Me.OpenArgs)
    End Sub

    In the rest of the code, use strCaller instead of Me.OpenArgs. For example, to make the calling form visible:

    Forms(strCaller).Visible = True

    and to close the calling form:

    DoCmd.Close acForm, strCaller

    (Note the argument acForm before the form name)

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    Littleton, Colorado, USA
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Generic 'CloseForm' (A2K/SR1)

    That did it, Hans. Thanks. I'm still having trouble with the cascading forms, though. Everything is starting from a standard switchboard. When the user clicks on the button for frmOriginal, I have the following in the Form_Load event:
    <pre>Forms("frmOriginal").Visible = False
    DoCmd.OpenForm "frmUserInput", , , , , , "frmOriginal"</pre>


    I have the switchboard set to maximize when it opens. To give the database an application look and feel, I have each from the switchboard launches set up as a popup form, with modal set to false. The popup form, frmUserInput, has modal set to True so the user is forced to take action. The problem is that when the switchboard opens frmOriginal, the frmOriginal opens frmUserInput, frmOriginal stays on top, partly obsuring frmUserInput. That's why I'm trying to set frmOriginal.Visible to false. Perhaps there's a method to set a form's "Z-Height?"

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

    Re: Generic 'CloseForm' (A2K/SR1)

    There should be no problem in setting the Visible property of frmOriginal to False. What goes wrong?

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    Littleton, Colorado, USA
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Generic 'CloseForm' (A2K/SR1)

    I'm afraid nothing, Hans; that's the problem. The original form stays visible and obscures it's calling form. I've made it my front end, so I'll need to work up a stripped down database to show you, I think.

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

    Re: Generic 'CloseForm' (A2K/SR1)

    I just tested it - it works for me with a setup like you describe, so it would be useful to see (a copy of) your database.

  7. #7
    Star Lounger
    Join Date
    Jan 2001
    Location
    Littleton, Colorado, USA
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Generic 'CloseForm' (A2K/SR1)

    I neglected to mention I also set the border dialog property of both frmOriginal and frmUserInput to Dialog, Hans. I don't know whether that would make a difference (or why, for that matter). Regardless, here's a test database. I works just as I described.

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

    Re: Generic 'CloseForm' (A2K/SR1)

    The Border Style property does not matter.

    > Regardless, here's a test database.

    I don't see an attachment. See <post#=401925>post 401925</post#> for instructions on how to attach a database.

  9. #9
    Star Lounger
    Join Date
    Jan 2001
    Location
    Littleton, Colorado, USA
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Generic 'CloseForm' (A2K/SR1)

    Sorry, Hans; I previewed my posted after attaching the database. Here's the file.

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

    Re: Generic 'CloseForm' (A2K/SR1)

    The problem is that you open frmUserInput from the On Load event of frmOriginal, when frmOriginal hasn't been displayed yet. The problem wouldn't occur if you opened frmUserInput from a command button on frmOriginal or something like that. If you want to display frmUserInput before frmOriginal, open frmUserInput from the switchboard.

  11. #11
    Star Lounger
    Join Date
    Jan 2001
    Location
    Littleton, Colorado, USA
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Generic 'CloseForm' (A2K/SR1)

    Well, in this particular case, I wanted to add a simple layer of security and require a password to open frmOriginal. This makes it impractical to add a button to ask for a password onto frmOriginal. I could, I suppose, disable all the controls on frmOriginal at the beginning and only unlock the controls after the user has entered an appropriate password, but this is less intuitive than simply popping up a password form. I had though about adding another field to the Switchboard table indicating a protected form, then modifying the underlying Switchboard form code, but I have a feeling that would create issues with the built-in Switchboard Manager.

    By the way, I know something about user level security, and I don't believe it covers password-protected forms, which is what I'm trying to accomplish. Unless anyone has a clever way to do this, I'll work on some other, more important issues in the database, like better filtering for reports, or a good help system, or.... <img src=/S/coffeetime.gif border=0 alt=coffeetime width=32 height=48>

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

    Re: Generic 'CloseForm' (A2K/SR1)

    You can open frmUserInput from the Switchboard, then open frmOriginal from frmUserInput. If you want frmUserInput to be generic, you CAN add another field to the Switchboard Items table, and pass that as OpenArgs. As long as you don;t modify the original fields in the Switchboard Items table, this won;t interfere with the working of the Switchboard. Of course, you'll have to fill this extra field manually, the Switchboard Manager doesn't know about it.

  13. #13
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Generic 'CloseForm' (A2K/SR1)

    <hr>By the way, I know something about user level security, and I don't believe it covers password-protected forms, which is what I'm trying to accomplish. Unless anyone has a clever way to do this, . . .<hr>
    Actually we do this sort of thing using User Security fairly frequently. Using the function CurrentUser() you can determine who the user is, and then do all sorts of things, such as hiding a button that allows another form to be opened, or locking controls on a form so only certain people can edit, or display only certain information to some users, and all to others. Based on your description, it sounds like Access User Security should be useful.
    Wendell

  14. #14
    Star Lounger
    Join Date
    Jan 2001
    Location
    Littleton, Colorado, USA
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Generic 'CloseForm' (A2K/SR1)

    Thanks for the tips, Hans and Wendell. Since it would seem I'm almost there with the very simple security scheme I'd like, I'm going to try a Switchboard trick for the short term. After I get the database running, I'll look into the user level security.

Posting Permissions

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