Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2005
    Location
    Delaware
    Posts
    139

    Unanswered: Forms won't close

    Hello Everybody;

    I am using the following code to close some forms but they won't close. What am I missing here? I have used this code on many other forms and it works fine. Stumped !

    Private Sub cmd_Return_Click()

    DoCmd.Close , "frm_EditProductionData_Params"
    DoCmd.Close , "frm_EditProductionData_mgr"
    ' Go to Resolve switchboard
    DoCmd.OpenForm "SwitchboardMain", acNormal, "", "", , acNormal
    DoCmd.Maximize

    End Sub

    Thanks...
    Larry

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    do you get any errors???? Do those forms have dependencies????
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Aug 2005
    Location
    Delaware
    Posts
    139
    Hi M Owen;

    No errors. Dependencies... how do you mean? The forms in question does not need to be open for other forms to relate to. However, the frm_EditProductionData_Params I needed to be open (I think) until the query which feeds frm_EditProductionData_mgr ran. The code I attached below is located on the frm_EditProductionData_mgr cmd_Close button on that form. I left the frm_EditProductionData_Params form open while editing the data on frm_EditProductionData_mgr.

    I noticed the problem when I went back in to edit more data with different parameters, the ..._Params form still had the same data entered previously because the form never closed. I even tried to code the on-open event of the ..._Params form with StartDate = "" (one of the parameters on the form). But that didn't clear the controls (unbound controls).

    Larry

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    ? shouldn't it be
    docmd.close acform, "nameOfForm"

    i see you have the , in there, so maybe acform is the default and i'm talking crap again.

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    No, acDefault (whatever that is) is, oddly enough, the default, so he does need the acForm!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Join Date
    Aug 2005
    Location
    Delaware
    Posts
    139
    Hello Everyone;

    Well that did it... added acForm, bla and the forms are now closing. This is so weird... I have many forms that I close using the exact same code (without the acForm) and they close just fine. Normally I don't even use the name, just DoCmd,Close , "". Could that be the difference... specifying the name?

    Thanks...

    Larry

  7. #7
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    2K3 help says:
    expression.Close(ObjectType, ObjectName, Save)
    If you leave the objecttype and objectname arguments blank (the default constant, acDefault, is assumed for objecttype), Microsoft Access closes the active window.


    izy
    currently using SS 2008R2

Posting Permissions

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