Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Closing & opening forms (XP, 2000)

    I am trying to have a command button that when clicke will close the current form and open another (switchboard). Here is the code I have - it opens the switchboard fine but does not close the original form (testform2). What am I missing?

    Private Sub Command0_Click()
    On Error GoTo Err_Command0_Click
    Close testform2
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "Switchboard"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit_Command0_Click:
    Exit Sub
    Err_Command0_Click:
    MsgBox Err.Description
    Resume Exit_Command0_Click
    End Sub

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

    Re: Closing & opening forms (XP, 2000)

    The instruction Close testform2 is not valid for closing a form. Use

    DoCmd.Close

    or, if you want to be precise,

    DoCmd.Close acForm, Me.Name, acSaveNo

  3. #3
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing & opening forms (XP, 2000)

    <P ID="edit" class=small>(Edited by Don_Sadler on 13-Dec-03 15:51. added the form name that I should have included)</P>Thank you Hans, the second one worked. I had previously tried "DoCmd.Close testform2" and it didn't work - said I needed an argument but I could not determine what argument was needed.

Posting Permissions

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