Results 1 to 6 of 6
  1. #1
    taylorosso is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    29

    close form

    i am trying to construct the navigation of my database forms.

    Am having trouble when it comes to opening one form and then closing the previous form.

    here is the code i am using however the 'doCmd.close' seems to be refering to the wrong form so what happens is it opens my desired form then immedietley closes it again. Rather than opening my new form then closing the old form.

    here is the code:


    Private Sub Command3_Click()
    On Error GoTo Err_Command3_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmClients"

    stLinkCriteria = "[ClientID]=" & Me!
    [List3]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    DoCmd.Close



    Exit_Command3_Click:
    Exit Sub

    Err_Command3_Click:
    MsgBox Err.Description
    Resume Exit_Command3_Click

    End Sub
    is ther a way to specifically refer to a desired form in order to close it using 'doCmd.close'.

    cheers

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    From VBA Help: expression.Close(ObjectType, ObjectName, Save)

  3. #3
    taylorosso is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    29
    i changed the code using your solution but it appears ive got it wrong.
    When i try to run the code I get a message saying 'Compile Error expected "=" '

    Heres what i amended to;


    Private Sub Command3_Click()
    On Error GoTo Err_Command3_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmClients"

    stLinkCriteria = "[ClientID]=" & Me!
    [List3]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    DoCmd.Close (acForm, "frmSearchClient2" ,acSaveYes)


    Exit_Command3_Click:
    Exit Sub

    Err_Command3_Click:
    MsgBox Err.Description
    Resume Exit_Command3_Click

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Just leave off the parens.
    DoCmd.Close acForm, "frmSearchClient2" , acSaveYes

  5. #5
    taylorosso is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    29
    thanks for your help again RuralGuy, its working perfectly

    Unfortunatley im not too good at VB so i get stuck alot on the little things.

    Im sure you'll be hearing from me again sometime soon with a new dilema

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Glad to help. I *like* the easy questions!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Running a Delete (Records) Query on Close
    By NoiCe in forum Queries
    Replies: 1
    Last Post: 07-12-2009, 06:17 PM
  2. Unable to close Query without saving
    By jhrBanker in forum Access
    Replies: 0
    Last Post: 06-08-2009, 05:09 PM
  3. Replies: 0
    Last Post: 08-25-2008, 12:17 PM
  4. Replies: 1
    Last Post: 12-21-2005, 12:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums