Createreportcontrol confusion for dynamic adding of textboxes/labe

G

Guest

I want to give the user the ability to add 1 to 3 new fields to a report.
When I run the code below, I find that the detail is okay. The problem is
with the headers and footers in the report. Nothing is being placed in the
section that I code.
HELP!

the code:
'**********
Cnt + 1 'tally of fields chosen
Select Case ctl.NAME
Case "chkSelect1" 'Outbound column
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Header, "", "", (8250 + (770 * Cnt)), 660, 750, 663)
ctlLabel.Caption = "Outbound Calls TalkTime"
ctlLabel.NAME = "lblAdd" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail,
"", "DNoutExtCallsTalkTime", (8250 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyA" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail,
"", "DNoutIntCallsTalkTime", (8625 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyB" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8

Case "chkSelect2" 'Inbound column
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail,
"", "DNInExtCalls", (8250 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyA" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail,
"", "DNInIntCalls", (8625 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyB" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Header, "", "", (8250 + (770 * Cnt)), 660, 750, 663)
ctlLabel.Caption = "Inbound Calls TalkTime"
ctlLabel.NAME = "lblAdd" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8

Case "chkSelect3" 'Talk Time column
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail, "",
"TalkTime(min)", (8250 + (770 * Cnt)), 240, 750, 270)
ctlText.NAME = "txtDaily" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Header, "", "", (8250 + (770 * Cnt)), 660, 750, 663)
ctlLabel.Caption = " TalkTime (min)"
ctlLabel.NAME = "lblAdd" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox,
acGroupLevel1Footer, "", "=Sum([TalkTime(min)])", (8250 + (770 * Cnt)), 930,
750, 270)
ctlText.NAME = "txtTot" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Footer, ctlText.NAME, "", (8250 + (770 * Cnt)), 465, 750, 465)
ctlLabel.Caption = "Total TalkTime"
ctlLabel.NAME = "lblTot" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
If AssocSkill = "coach" Then
Set ctlText = CreateReportControl(RptName, acTextBox,
acGroupLevel2Footer, "", "=Sum([TalkTime(min)])", (8250 + (770 * Cnt)), 930,
750, 270)
ctlText.NAME = "txtTotC3"
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel2Footer, ctlText.NAME, "", (8250 + (770 * Cnt)), 465, 750, 465)
ctlLabel.Caption = "Total TalkTime"
ctlLabel.NAME = "lblTotC3"
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
End If
'*********
 
M

Marshall Barton

You're barking up the wrong tree??

CreateControl should only be used in a design time wizard,
not in a runtim procedure.

A far better way to accomplish the goal is to add the
controls at design time and make them visible/invisible as
needed at runtime.
--
Marsh
MVP [MS Access]


Steve said:
I want to give the user the ability to add 1 to 3 new fields to a report.
When I run the code below, I find that the detail is okay. The problem is
with the headers and footers in the report. Nothing is being placed in the
section that I code.
HELP!

the code:
'**********
Cnt + 1 'tally of fields chosen
Select Case ctl.NAME
Case "chkSelect1" 'Outbound column
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Header, "", "", (8250 + (770 * Cnt)), 660, 750, 663)
ctlLabel.Caption = "Outbound Calls TalkTime"
ctlLabel.NAME = "lblAdd" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail,
"", "DNoutExtCallsTalkTime", (8250 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyA" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail,
"", "DNoutIntCallsTalkTime", (8625 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyB" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8

Case "chkSelect2" 'Inbound column
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail,
"", "DNInExtCalls", (8250 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyA" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail,
"", "DNInIntCalls", (8625 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyB" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Header, "", "", (8250 + (770 * Cnt)), 660, 750, 663)
ctlLabel.Caption = "Inbound Calls TalkTime"
ctlLabel.NAME = "lblAdd" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8

Case "chkSelect3" 'Talk Time column
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail, "",
"TalkTime(min)", (8250 + (770 * Cnt)), 240, 750, 270)
ctlText.NAME = "txtDaily" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Header, "", "", (8250 + (770 * Cnt)), 660, 750, 663)
ctlLabel.Caption = " TalkTime (min)"
ctlLabel.NAME = "lblAdd" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox,
acGroupLevel1Footer, "", "=Sum([TalkTime(min)])", (8250 + (770 * Cnt)), 930,
750, 270)
ctlText.NAME = "txtTot" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Footer, ctlText.NAME, "", (8250 + (770 * Cnt)), 465, 750, 465)
ctlLabel.Caption = "Total TalkTime"
ctlLabel.NAME = "lblTot" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
If AssocSkill = "coach" Then
Set ctlText = CreateReportControl(RptName, acTextBox,
acGroupLevel2Footer, "", "=Sum([TalkTime(min)])", (8250 + (770 * Cnt)), 930,
750, 270)
ctlText.NAME = "txtTotC3"
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel2Footer, ctlText.NAME, "", (8250 + (770 * Cnt)), 465, 750, 465)
ctlLabel.Caption = "Total TalkTime"
ctlLabel.NAME = "lblTotC3"
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
End If
'*********
 
G

Guest

In the earilier code, I open the report in design view and hidden, then run
the code that you read. I want to be able to left justify any of the columns
that are selected.
When you design all of the columns and then make the selected ones visible,
then you can have column gaps in the preview of the report. This is why I
did what I did.....

thanks for the comments.

Marshall Barton said:
You're barking up the wrong tree??

CreateControl should only be used in a design time wizard,
not in a runtim procedure.

A far better way to accomplish the goal is to add the
controls at design time and make them visible/invisible as
needed at runtime.
--
Marsh
MVP [MS Access]


Steve said:
I want to give the user the ability to add 1 to 3 new fields to a report.
When I run the code below, I find that the detail is okay. The problem is
with the headers and footers in the report. Nothing is being placed in the
section that I code.
HELP!

the code:
'**********
Cnt + 1 'tally of fields chosen
Select Case ctl.NAME
Case "chkSelect1" 'Outbound column
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Header, "", "", (8250 + (770 * Cnt)), 660, 750, 663)
ctlLabel.Caption = "Outbound Calls TalkTime"
ctlLabel.NAME = "lblAdd" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail,
"", "DNoutExtCallsTalkTime", (8250 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyA" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail,
"", "DNoutIntCallsTalkTime", (8625 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyB" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8

Case "chkSelect2" 'Inbound column
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail,
"", "DNInExtCalls", (8250 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyA" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail,
"", "DNInIntCalls", (8625 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyB" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Header, "", "", (8250 + (770 * Cnt)), 660, 750, 663)
ctlLabel.Caption = "Inbound Calls TalkTime"
ctlLabel.NAME = "lblAdd" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8

Case "chkSelect3" 'Talk Time column
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail, "",
"TalkTime(min)", (8250 + (770 * Cnt)), 240, 750, 270)
ctlText.NAME = "txtDaily" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Header, "", "", (8250 + (770 * Cnt)), 660, 750, 663)
ctlLabel.Caption = " TalkTime (min)"
ctlLabel.NAME = "lblAdd" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox,
acGroupLevel1Footer, "", "=Sum([TalkTime(min)])", (8250 + (770 * Cnt)), 930,
750, 270)
ctlText.NAME = "txtTot" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Footer, ctlText.NAME, "", (8250 + (770 * Cnt)), 465, 750, 465)
ctlLabel.Caption = "Total TalkTime"
ctlLabel.NAME = "lblTot" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
If AssocSkill = "coach" Then
Set ctlText = CreateReportControl(RptName, acTextBox,
acGroupLevel2Footer, "", "=Sum([TalkTime(min)])", (8250 + (770 * Cnt)), 930,
750, 270)
ctlText.NAME = "txtTotC3"
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel2Footer, ctlText.NAME, "", (8250 + (770 * Cnt)), 465, 750, 465)
ctlLabel.Caption = "Total TalkTime"
ctlLabel.NAME = "lblTotC3"
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
End If
'*********
 
D

Duane Hookom

It's much easier to set the Left (and other) property at run time than it is
to create controls from scratch.

--
Duane Hookom
MS Access MVP
--

Steve G said:
In the earilier code, I open the report in design view and hidden, then
run
the code that you read. I want to be able to left justify any of the
columns
that are selected.
When you design all of the columns and then make the selected ones
visible,
then you can have column gaps in the preview of the report. This is why I
did what I did.....

thanks for the comments.

Marshall Barton said:
You're barking up the wrong tree??

CreateControl should only be used in a design time wizard,
not in a runtim procedure.

A far better way to accomplish the goal is to add the
controls at design time and make them visible/invisible as
needed at runtime.
--
Marsh
MVP [MS Access]


Steve said:
I want to give the user the ability to add 1 to 3 new fields to a
report.
When I run the code below, I find that the detail is okay. The problem
is
with the headers and footers in the report. Nothing is being placed in
the
section that I code.
HELP!

the code:
'**********
Cnt + 1 'tally of fields chosen
Select Case ctl.NAME
Case "chkSelect1" 'Outbound column
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Header, "", "", (8250 + (770 * Cnt)), 660, 750, 663)
ctlLabel.Caption = "Outbound Calls TalkTime"
ctlLabel.NAME = "lblAdd" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox,
acDetail,
"", "DNoutExtCallsTalkTime", (8250 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyA" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox,
acDetail,
"", "DNoutIntCallsTalkTime", (8625 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyB" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8

Case "chkSelect2" 'Inbound column
Set ctlText = CreateReportControl(RptName, acTextBox,
acDetail,
"", "DNInExtCalls", (8250 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyA" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox,
acDetail,
"", "DNInIntCalls", (8625 + (770 * Cnt)), 240, 375, 270)
ctlText.NAME = "txtDailyB" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Header, "", "", (8250 + (770 * Cnt)), 660, 750, 663)
ctlLabel.Caption = "Inbound Calls TalkTime"
ctlLabel.NAME = "lblAdd" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8

Case "chkSelect3" 'Talk Time column
Set ctlText = CreateReportControl(RptName, acTextBox, acDetail,
"",
"TalkTime(min)", (8250 + (770 * Cnt)), 240, 750, 270)
ctlText.NAME = "txtDaily" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Header, "", "", (8250 + (770 * Cnt)), 660, 750, 663)
ctlLabel.Caption = " TalkTime (min)"
ctlLabel.NAME = "lblAdd" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
Set ctlText = CreateReportControl(RptName, acTextBox,
acGroupLevel1Footer, "", "=Sum([TalkTime(min)])", (8250 + (770 * Cnt)),
930,
750, 270)
ctlText.NAME = "txtTot" & Cnt
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel1Footer, ctlText.NAME, "", (8250 + (770 * Cnt)), 465, 750,
465)
ctlLabel.Caption = "Total TalkTime"
ctlLabel.NAME = "lblTot" & Cnt
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
If AssocSkill = "coach" Then
Set ctlText = CreateReportControl(RptName, acTextBox,
acGroupLevel2Footer, "", "=Sum([TalkTime(min)])", (8250 + (770 * Cnt)),
930,
750, 270)
ctlText.NAME = "txtTotC3"
ctlText.TextAlign = 2
ctlText.FontSize = 8
Set ctlLabel = CreateReportControl(RptName, acLabel,
acGroupLevel2Footer, ctlText.NAME, "", (8250 + (770 * Cnt)), 465, 750,
465)
ctlLabel.Caption = "Total TalkTime"
ctlLabel.NAME = "lblTotC3"
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 8
End If
'*********
 
M

Marshall Barton

What Duane said.

You have already calculated the control's Left property in
your CreateControl procedure, so, instead of calling
CreateControl, just set an existing text box's Left
property.
--
Marsh
MVP [MS Access]


Steve said:
In the earilier code, I open the report in design view and hidden, then run
the code that you read. I want to be able to left justify any of the columns
that are selected.
When you design all of the columns and then make the selected ones visible,
then you can have column gaps in the preview of the report. This is why I
did what I did.....
[snip]
 

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

Dynamic Report 4

Top