I know that Access does not like the underscore character for object naming
purposes. Have you tried removing the underscrore char from your sample
code? Normally we would simply enclose any object name containing a leading
underscore char within square barackets[ ] but that would not work here.
--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
<jess@askey.org> wrote in message
news:1127162242.928209.68120@f14g2000cwb.googlegro ups.com...[color=blue]
> Hi,
>
> Im using the following code to make a new report based on an existing
> report.
>
> Set rpt = CreateReport(, "_SemiAnnualMaster")
>
> The problem that I am running into is that none of the report controls
> are coming across. All I end up with is a blank report. So, I manually
> copied all the Labels, Text boxes etc across..
>
> Dim ctl As Access.Control
> Dim ctlNewLabel As Access.Label
> Dim ctlNewtextBox As Access.TextBox
> Dim ctlNewLine As Access.Line
>
> For Each ctl In rptMaster.Controls
> Select Case ctl.Properties("ControlType")
> Case Access.acLabel:
> Set ctlLabel = ctl
> Set ctlNewLabel = CreateReportControl(rpt.Name,
> acLabel, ctlLabel.Section, , , ctlLabel.Left, ctlLabel.Top,
> ctlLabel.Width, ctlLabel.Height)
> ctlNewLabel.Name = ctlLabel.Name
> ctlNewLabel.Caption = ctlLabel.Caption
> ctlNewLabel.TextAlign = ctlLabel.TextAlign
> Case Access.acTextBox:
> Set ctlTextBox = ctl
> Set ctlNewtextBox = CreateReportControl(rpt.Name,
> acTextBox, ctlTextBox.Section, , ctlTextBox.ControlSource,
> ctlTextBox.Left, ctlTextBox.Top, ctlTextBox.Width, ctlTextBox.Height)
> ctlNewtextBox.Name = ctlTextBox.Name
> ctlNewtextBox.TextAlign = ctlTextBox.TextAlign
> 'ctlNewtextBox.DefaultValue = ctlTextBox.DefaultValue
> Case Access.acLine:
> Set ctlLine = ctl
> Set ctlNewLine = CreateReportControl(rpt.Name, acLine,
> ctlLine.Section, , , ctlLine.Left, ctlLine.Top, ctlLine.Width,
> ctlLine.Height)
> ctlNewLine.Name = ctlLine.Name
> Case Else
>
> End Select
>
> Next ctl
>
> DoCmd.Close acReport, "_SemiAnnualMaster", acSaveNo
>
> After this, the issue Im running into is that none of the templates
> grouping colums are in the new report. Before I start trying to copy
> the grouping via code, I seem to be thinking that the usefulness of
> CreateReport is very small unless I am missing something. I thought
> that this may be an issue with the recordsource of the template being
> broken because I can see how that may effect controls. Unfortunately,
> even my non-databound controls are not being created with CreateReport.
> I set recordsource correctly in the template report and I still get an
> empty report upon using CreateReport specifying that template name.
>
> Are there any reason's why I might get an empty report using
> CreateReport that anyone knows of or is CreateReport totally useless?
> ;-) Should I examine my rowsource more closely perhaps? CreateReport( ,
> templateName) seemed like it would be so useful if I could get it
> working.
>
> thank you
>[/color]