Do.Cmd Close Not Working

B

bw

After I close my report, the input form I'm using is apparently still open.
I know this, because default values on the form are set to my last
selection, and if I try to set the form property to hidden, Access tells me
I can't do that because the form is still open.

Can someone please explain what's going on? The following is my report
code:

Private Sub Report_Open(Cancel As Integer)
Dim strDocName As String
strDocName = "boxSeatsMailings"
blnOpening = True
DoCmd.OpenForm strDocName, , , , , acDialog
If Not (IsLoaded(strDocName)) Then
MsgBox "Report has been cancelled"
Cancel = True
Exit Sub
Else
blnOpening = False
DoCmd.SetWarnings False
DoCmd.Maximize
DoCmd.SetWarnings True
End If
End Sub

Private Sub Report_Close()
DoCmd.Close acForm, "boxSeatsMailing"
DoCmd.Restore
End Sub
 
F

fredg

After I close my report, the input form I'm using is apparently still open.
I know this, because default values on the form are set to my last
selection, and if I try to set the form property to hidden, Access tells me
I can't do that because the form is still open.

Can someone please explain what's going on? The following is my report
code:

Private Sub Report_Open(Cancel As Integer)
Dim strDocName As String
strDocName = "boxSeatsMailings"
blnOpening = True
DoCmd.OpenForm strDocName, , , , , acDialog
If Not (IsLoaded(strDocName)) Then
MsgBox "Report has been cancelled"
Cancel = True
Exit Sub
Else
blnOpening = False
DoCmd.SetWarnings False
DoCmd.Maximize
DoCmd.SetWarnings True
End If
End Sub

Private Sub Report_Close()
DoCmd.Close acForm, "boxSeatsMailing"
DoCmd.Restore
End Sub


You have miss-spelled "boxSeatsMailings", as you open that form,
but you are closing "boxSeatsMailing" (no final s).

You have code in your code that is not doing anything.
Let's simplify it.
Try it this way and see if it works.
I'll assume you want that final "s".

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "boxSeatsMailings" , , , , , acDialog
If Not IsLoaded("boxSeatsMailings") Then
MsgBox "Report has been cancelled"
Cancel = True
Exit Sub
Else
DoCmd.Maximize
End If
End Sub

Private Sub Report_Close()
DoCmd.Close acForm, "boxSeatsMailings"
DoCmd.Restore
End Sub

Make sure you have the name spelled the same in the Open and Close
events. <g>
 
B

bw

fredg said:
You have miss-spelled "boxSeatsMailings", as you open that form,
but you are closing "boxSeatsMailing" (no final s).

You have code in your code that is not doing anything.
Let's simplify it.
Try it this way and see if it works.
I'll assume you want that final "s".

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "boxSeatsMailings" , , , , , acDialog
If Not IsLoaded("boxSeatsMailings") Then
MsgBox "Report has been cancelled"
Cancel = True
Exit Sub
Else
DoCmd.Maximize
End If
End Sub

Private Sub Report_Close()
DoCmd.Close acForm, "boxSeatsMailings"
DoCmd.Restore
End Sub

Make sure you have the name spelled the same in the Open and Close
events. <g>

Wow Fred!

I have spent several days puttering with this trying to find out what was
wrong, but I just couldn't see what you did.
Your solution of course fixed the problem, and worse, since the file was not
closing, it is now obvious that it must have been a problem with the Close
statement, and with only two lines of code, one would think that it would
have been the first place I looked.

You ended with <g>, but I'll end with bummer!

Thanks for your patient understanding from this humble part time programmer.
Bernie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Print based on control 3
Records/Forms/Querys 4
opening forms 1
Open report with forms-data-entry 2
Date Range in 2007 10
Main Report without Data 1
run-time error 2501 1
Open Date range Dialog Box From Report 2

Top