Results 1 to 2 of 2
  1. #1
    degras is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    72

    Modal form does not close after OK clicked

    I have a modal form that I open with:
    DoCmd.OpenForm "DatesForm"

    There is an on click event for the OK button on the form:
    Private Sub Command1_Click()
    DoCmd.OpenReport "MultiInvoice", acViewPreview, , "Company = '" & _
    Me.CompanyNameText & "' And InvoiceDate >= #" & Me.StartDateText & _
    "# And InvoiceDate <= #" & Me.EndDateText & "#", , "Group"
    End Sub



    ... which runs a report OK, but the form does not close after the OK button is clicked, so the report is under the modal form. If I click cancel to close the form and then click on the tab to get the report I get an error: 2455. How do I get the form to close automatically and show the report without any error?

    Thanks.

    ... Don't worry I sorted this. I used DoCmd.Close, but I made sure to store the text box values into variables beforehand.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Just before End Sub put: DoCmd.Close acForm, Me.Name, acSaveNo

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

Similar Threads

  1. Replies: 6
    Last Post: 02-10-2011, 09:58 AM
  2. How to refresh and close a form
    By LAazsx in forum Forms
    Replies: 10
    Last Post: 12-13-2010, 06:24 AM
  3. Replies: 1
    Last Post: 11-09-2010, 03:02 PM
  4. Close All but One Form
    By Bruce in forum Forms
    Replies: 4
    Last Post: 04-06-2010, 09:31 AM
  5. close form
    By taylorosso in forum Forms
    Replies: 5
    Last Post: 08-25-2009, 12:18 PM

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