View Full Version : Save As prompt from CreateReportControl and DeleteReportControl


tuxDPenguin
09-15-2006, 02:02 PM
This is fixed, so pay no attention, I couldn't figure out how to change the topic though. :)

Let me preface this with I'm not an Access or VB developer, so this might be simple, but despite that I am stuck with this assignment and i've googled till i'm blue in the face. :confused:

i'm just converting an access 97 program to 2003, in 97 this code runs silently with no problem, in 2003 a window pops up, i'm trying to get rid of that window.

this code:

subrptName is a string
rptChart is a report
ctlReport is a control

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

on that second to last line, DoCmd.Close, pops up this window:

please and thank you! :D

boblarson
09-15-2006, 03:56 PM
That line of code is saying that you want to save the report at the end and so it is giving you a dialog to designate the name of the report you want to save it as.

If you don't want to save it, then the code would be:

DoCmd.Close acReport, subrptName, acSaveNo

tuxDPenguin
09-20-2006, 02:48 PM
hi bob

well, i assume i want to save it though... see this code runs without any prompts in 97, but it brings up that prompt in 2003, i'm just trying to figure out what has changed.

there's also several sections of code like this, and they all end with acSaveYes, the only thing that makes this bit different than the others is opening it in acViewDesign and the deletereportcontrols/createreportcontrols.

:confused: oh well thanks

tuxDPenguin
10-27-2006, 07:13 AM
I actually fixed this by adding an explicit save right away near the top,

DoCmd.Save acReport, rptName

see whenever the subreport got modified and then closed, i got yelled at the main report wasn't saved. so i just end having to save it twice, but i got no problem with that, as long as the annoying prompt goes away!