Results 1 to 11 of 11
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need Help Closing Form? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I have a frmMenu that has a button to open frmA (transaction entry form)

    In frmA Form_Open I open frmB (btach information, date, batch no, etc) so operator can enter batch information that will be used when they return to frmA to enter transactions.

    On frmB I also have a Cancel button that closes frmB and returns to frmA

    What code do I need to add to frmB to close frmB, frmA and return to frmMenu?

    I tried the following and received

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Need Help Closing Form? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    John,

    Which line of code is giving you the error?
    What form is this button on?
    Where are you tests for IsLoaded before trying to close the forms?
    Do you need code to make your main menu visible or to load it?
    Charlotte

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need Help Closing Form? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Congratulations on your promotion!

    1. The error is on this line

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Need Help Closing Form? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I thought in your original post you were referring to an error in those lines of code. <img src=/S/confused.gif border=0 alt=confused width=15 height=20>
    Here, you're opening frmB as a dialog, which should pause the code in frmA until you close frmB. OpenArgs sometimes becomes unreliable if you have shelled out to another process, like another form, and I don't understand why you would not process the Form_Open code for frmA until after you open and close frmB. frmB is NOT going to pass any OpenArgs back to frmA, if that's what you're trying to do.
    Charlotte

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need Help Closing Form? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Look at attached db

    1. Open frmMenu
    2. Open Form A
    3. Close Form B and A (this is what I want to do without generating error)

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Need Help Closing Form? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I'll take a look at it this evening, but I can tell you that the problem is probably because you have opened frmB as a dialog and tried to close frmA. However, frmA has code waiting to run which can't run because you've told it to close when it hasn't finished opening. You could try opening frmB *after* the rest of the code in frmA and see if that makes a difference.
    Charlotte

  7. #7
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need Help Closing Form? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Charlotte is right (as always). It is the acDialog that breaks the code.
    A solution if it's usable for you : use an On Error Resume Next in the code from frmA<pre>Private Sub Form_Open(Cancel As Integer)
    DoCmd.OpenForm "frmB", , , , , acDialog, Me.Name
    On Error Resume Next
    If IsNull(Me.OpenArgs) Then
    Me.RecordSource = "tbl1"
    Else
    If (Me.OpenArgs) = "Check Writer" Then
    Me.RecordSource = "tbl2"
    End If
    End If
    End Sub</pre>

    Francois

  8. #8
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need Help Closing Form? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Hi Charlotte & Francois

    I applied On Error Resume Next in the demo I sent and it runs OK

    In my production system I

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Need Help Closing Form? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Insert a breakpoint and step through it to see what line of code is highlighted. Otherwise, we're just guessing.
    Charlotte

  10. #10
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need Help Closing Form? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    After further review with breakpoint, problem was with the calls (that you didn

  11. #11
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Need Help Closing Form? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    How many do you need? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Actually, you could probably move most of that code to the Form_Load event and you might not need a lot of error handling because it should never fire there if the form is closed from frmB.
    Charlotte

Posting Permissions

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