Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Closing a Form Unoticed (A2K)

    Here comes another one of my weird requests. Don't even begin to suggest otherwise.

    Scenario:

    I have a form.
    I create a new record.
    I want to save this new record.
    The only way that it works in this particular, you don't want to know the gruesome details, situation is if I close the form and then immediately reopen the same form.

    Problem:

    I am trying to open and close the form without it being overly noticeable. Right now, it obviously displays the closing and opening.

    Question:

    Can this be done transparentally, ie. make the opening/closing transparent?

    Thanks in advance to those of you who are also working on Labour/Labor Day,
    Cheers,
    Andy

  2. #2
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a Form Unoticed (A2K)

    Why don't you requery, refresh the form instead ?, that way you don't need to close the form at all !!

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a Form Unoticed (A2K)

    Dave, thanks kindly for the quick reply. Under "normal" circumstances, the requery routine is what I usually do as well. As I alluded to in my original request, this is a 'unique' situation, way too long to even begin to explain what necessitates this way off-centre approach to what I'm doing. So....... I'm still looking for a 'turn off the screen' scenario. I'm sure that I've seen this done before, and I'm pretty sure it wasn't when I was using COBOL, so the answer must be out there somewhere, Anyway, thanks again, and why are you also working today?
    Cheers,
    Andy

  4. #4
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a Form Unoticed (A2K)

    Andy

    Can you not just save the record instead ?
    I'm probably covering old ground with issues you already know of, but for the life of me, can't see a neccessity to close and re-open just to save a record.

    Wouldn't a "DoCmd.RunCommand acCmdSaveRecord" do the task in the After_Update of some control?

    Other than that, what about distracting the user in some way with a popup form "Please Wait" or something ?


    <font color=blue>and why are you also working today?</font color=blue>

    I thought it was quiet in here today !!

  5. #5
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a Form Unoticed (A2K)

    Dave, thanks for your patience. I have a tendancy of designing forms that enable the user to run everything they ever wanted to do without going to other forms so that I end up with very complex, but much appreciated single, multi-tabbed forms. And they want everything to happen "Automatically". In this case, it is doing the entire model home costing scenario for a homebuilder. In one form. 300+ Controls. Not considered good form design by the 'learned ones' but totally attractive, desirable and satisfying to the client. He who pays the invoice.

    I did try the "DoCmd.RunCommand acCmdSaveRecord" within the combobox that is being used and in the process, earned myself a Run-time error '2501' which I managed to get myself out of, but still with no luck with respect to saving the record. In actual fact, and this could be a clue, it is not so much that I want to save the record at this exact point in time, but rather, be in a position to enter another new record, which won't happen until the previous one is saved and off the table, so to speak. But at some point, I'll still have to go to a 'Save' routine. I've also tried 'single' command buttons for SAVE, REQUERY, GoNEXT, "Get-Me-A-Beer", etc. All to now avail.

    Anyway, long story short, thanks kindly for your appreciated efforts, and it's do this or go out and clean the yard.

    Ps. And I'm almost afraid to ask this, but how exactly would I initiate this 'Turn Your Head the Other Way' message? Geez, if I can't do a stupid save on my own, I wonder how I'll do with a 'message'?
    OK, I'll go cut grass instead.
    Cheers,
    Andy

  6. #6
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a Form Unoticed (A2K)

    I cut mine yesterday !!

    Perhaps then creating a seperate table with your record numbers and linked to the table for your main form.
    You could always use this new table for a hidden subform, or welded nicely on the main not showing borders or deviding lines.
    This way you could create several record on the fly and requery the sub form only.

    Only thoughts !! and goodluck.

  7. #7
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Closing a Form Unoticed (A2K)

    I also don't know why you need to close & open form, but anyway, to respond to question re: how to turn off screen updates, you can use Windows LockWindowUpdate API function to turn off/turn on screen updating for a specified window. Example of use in Access:

    <code>Private Declare Function LockWindowUpdate Lib "user32" _</code>
    <code> (ByVal hwndLock As Long) As Long</code>

    <code>Public Sub LockScreenUpdate(bLock As Boolean)</code>
    <code> </code>
    <code> ' Always use with error handler - unlock window in event of error!</code>
    <code> ' Only one window can be locked at a time</code>
    <code> If bLock Then</code>
    <code> ' hwndLock = hwnd of window to lock - specify main app window:</code>
    <code> LockWindowUpdate Application.hWndAccessApp</code>
    <code> Else</code>
    <code> ' specify zero (as Long) to unlock window:</code>
    <code> LockWindowUpdate 0&</code>
    <code> End If</code>
    <code> </code>
    <code>End Sub</code>

    To turn off screen updates, call like this:

    <code>LockScreenUpdate True</code>

    To turn back on:

    <code>LockScreenUpdate False</code>

    The Application hWndAccessApp function returns the hwnd (handle) for main Access application window. Screen updates will be locked till turned back on by passing zero to function. You MUST use error handling if using this method to lock screen (unlock screen in the Exit Sub block) or else if an error occurs, the screen will remain locked & user will have terminate application using Task Manager.

    HTH

  8. #8
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a Form Unoticed (A2K)

    And good thoughts they are. The form is already approaching critical mass and working 99.99% except for this weird situation, so I think I'll a sleeping VBA Code lie and quit while I'm ahead. Cheers <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Cheers,
    Andy

Posting Permissions

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