Save As Prompt when closing a report

D

Douglas Hitchcock

I'm upgrading a 97 database to 2003. in 97 this code runs without problem
or hassle:

subrptName = "sub_rpt_Charts"
DoCmd.OpenReport subrptName, acViewDesign

x = 0
Set rptChart = Reports(subrptName)

For Each ctl In rptChart.Controls
ctlArray(x, 1) = ctl.Name
If ctl.ControlType = acBoundObjectFrame Then
ctlArray(x, 2) = True
Else
ctlArray(x, 2) = False
End If
x = x + 1
Next ctl
x = x - 1

For y = 0 To x
If ctlArray(y, 2) = True Then
DeleteReportControl rptChart.Name, ctlArray(y, 1)
End If
Next y

If chk_RunChart = True Then
chart1 = "RunChart"
If chk_Histogram = True Then
chart2 = "Histogram"
Else
chart2 = "StdDev"
End If
Else
chart1 = "Histogram"
chart2 = "StdDev"
End If

Set ctlReport = CreateReportControl(subrptName,
acBoundObjectFrame,
acDetail _, , , 0, 300, 4560, 2340)
ctlReport.ControlSource = chart1
ctlReport.SizeMode = acOLESizeStretch

Set ctlReport = CreateReportControl(subrptName,
acBoundObjectFrame,
acDetail _, , , 4620, 300, 4560, 2340)
ctlReport.ControlSource = chart2
ctlReport.SizeMode = acOLESizeStretch

If frme_Chart = 1 Then
rptChart.GroupLevel(0).ControlSource = "Product"
rptChart.GroupLevel(1).ControlSource = "Spec"
Else
rptChart.GroupLevel(1).ControlSource = "Product"
rptChart.GroupLevel(0).ControlSource = "Spec"
End If

Reports(subrptName).Filter = _
"([Product] " & strProd & ") AND ([Spec] " & strSpec & ")"
Reports(subrptName).FilterOn = True


DoCmd.SetWarnings False
DoCmd.Close acReport, subrptName, acSaveYes
DoCmd.SetWarnings True

Actually, the DoCmd.SetWarnings weren't even necessary in 97, but that
DoCmd.Close line at the end added two annoying popups in 2003.
SetWarnings False got rid of one of them, but I still get this prompt:

http://purplerhino.mailcan.com/saveas.png

what can I do to suppress that message? the code works fine if you just
click ok there, but I don't want to make a user do that.
 
G

Guest

Hi Douglas,

can you post the error message text in here, I can't access that website i'm
afraid.

TonyT..
 
D

Douglas Hitchcock

TonyT said:
Hi Douglas,

can you post the error message text in here, I can't access that website i'm
afraid.

TonyT..

Hey Tony

my email provider has been up and down a little today, the links working
at this moment. but if not still, it's just a dialog with Save As in
the title, one text box labeled "Report Name:" with a default value in
it of Report1, and an Ok and Cancel button on the right :)
 
G

Guest

Hmm strange,

what is the content of Report1 if you do choose to save the report, is it
the content of sub_rpt_charts or something different?

TonyT..
 
D

Douglas Hitchcock

TonyT said:
Hmm strange,

what is the content of Report1 if you do choose to save the report, is it
the content of sub_rpt_charts or something different?

TonyT..

:

Hey TonyT

thanks for trying to help, man I'd be so grateful to figure this out i
have seriously been stuck on this for weeks... so frustrating.

Anyway, nothing is in Report1, report1 never appears in the access
database, permanently anyway. I did make a change that caused it to
crash at that point, and so there was a Report1 (and the program just
went on to make Report2) and I looked at Report1 and it was the entire
report.

See this is one big report, and it goes through and has a lot of If this
checkbox is checked tack on this subreport routines that are very
similar to the one i posted here. All of them open and close subrptName
the same way, the thing that jumps out at me as different is this is the
only one that is opened with the acViewDesign flag, while the rest are
all just acDesign. I tried changing to acDesign though and that's what
caused the crash :)

doug
 
G

Guest

Ok lets start with the obvious things, what are all dim'd variables actually
dimmed as?

TonyT..
 
D

Douglas Hitchcock

TonyT said:
Ok lets start with the obvious things, what are all dim'd variables actually
dimmed as?

Hey Tony

sure, no prob. I'd give you whole method but it's huge, trying to not
give too much information to have to sift through... here are the Dims
at the top of the method

Dim rpt As Report
Dim ctlReport As Control
Dim NextPos As Integer
Dim MultiPage As Boolean
Dim PageBreak As Boolean
Dim Summary As Boolean
Dim selItem As Variant
Dim rptFilter As String
Dim rptMaster As String
Dim rptChild As String
Dim rptSource As String
Dim rptTitle As String
Dim rptDate As String
Dim rptName As String
Dim subrptName As String
Dim strProd As String
Dim strSpec As String
Dim strStatus As String 'used for Recommendations sub report only
Dim strAffected As String 'used for Recommendations sub report only
Dim rptChart As Report
Dim ctl As Control
Dim x As Integer
Dim y As Integer
Dim ctlArray(20, 2) As String
Dim chart1 As String
Dim chart2 As String
 
G

Guest

Well, if everything is working as it should do on the report except for this
1 remaining message, have you tried *hiding* it eg saving Report1 within your
code and then using deleteObject to delete it?

Not very elegant, but............if needs must.......

TonyT..
 
D

Douglas Hitchcock

TonyT said:
Well, if everything is working as it should do on the report except for this
1 remaining message, have you tried *hiding* it eg saving Report1 within your
code and then using deleteObject to delete it?

Not very elegant, but............if needs must.......

TonyT..

Hey Tony

I made the problem go away with an explicit DoCmd.Save before the
problem area. I'm not done with the file at that point, but when I had
modified a subreport it insisted I save the main one. So I save it
twice, no big whoop message box gone. THanks for your help :)
 

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

Top