Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

createcontrol type mismatch

Status
Not open for further replies.

tzigone

MIS
Aug 11, 2003
42
0
0
TR
hi,
i amtrying to add textboxes to my form by writing code with createcontrol; however run time error 13 type mismatch problem occurs The code is like this
createcontrol form_countreport,actextbox,"",""
what can i do?
 
Your third argument is shown as a String Data Type argument when in fact, it's a numeric (not sure which numeric type though presumably Long Data Type). Here's the section of the help file that you need to use one of the constants (or it's related value) for your command to work.

section One of the following intrinsic constants identifying the section that will contain the new control. To view these constants and paste them into your code from the Object Browser, click Object Browser on the Visual Basic toolbar, then click Access in the Project/Library box, and click AcSection in the Classes box.
Constant Section
acDetail (Default) Detail section
acHeader Form or report header
acFooter Form or report footer
acPageHeader Page header
acPageFooter Page footer
acGroupLevel1Header Group-level 1 header (reports only)
acGroupLevel1Footer Group-level 1 footer (reports only)
acGroupLevel2Header Group-level 2 header (reports only)
acGroupLevel2Footer Group-level 2 footer (reports only)
If a report has additional group levels, the header/footer pairs are numbered consecutively, beginning with 9.


Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
When the going gets tough, the tough gets going.
 
Dim ctltext As Control
Set ctltext = CreateControl(Form_countreport, acTextBox, acDetail)
type mismatch error occurs again.
 
Set ctltext = CreateControl("Form_countreport", acTextBox, acDetail)

First argument had to be in string format, not the actual form object.

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
When the going gets tough, the tough gets going.
 
thank you for your help. I write the code as you offer, this time it says: access can't find the 'Form_countreport' referred to in a macro expression or VBA code.
i write ME instead of name of the form, this time different error occured.
 
sorry i was writing name of form wrong. :))
this does not mean unfortunately end of error messages.
this time it says access can not add, rename or delete the controls.:((
 
Sorry for the long delay as I was on vacation over the holidays and then last week was my year end reporting week. At this point, I'm not really sure what could cause that particular error unless it's dealing with some sort of security setting that you have put in place or the "Allow Design Changes" on the form has been set to "Design View Only".

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
When the going gets tough, the tough gets going.
 
Ronald,

I'm having a similar problem, well, maybe not similar. I'm doing the same thing, writing a report by using code (I have my reasons...). The problem I'm running into is that when I try to put a label in acGroupLevel1Header I get the error "Run Time Error '2148': The number you used to refer to the form or report section is invalid."

The code in question is:

Code:
Set ctlLabel2 = CreateReportControl(strReportName, acLabel, acGroupLevel1Header, , , 60, 60, 5100, 600)

It's in the right place, I just can't figure out how to define a report section correctly, apparently.

I appreciate your help!


thx!

Q-
 
Hi,
i ask the same question (my q) in msaccessforums.com and the answer is you can't add control when the form is open and an open form's state can't be changed to design view when it is open. Even if you try to close the form and after that try to open it in design view, access does not allow.
As a matter of fact it becomes illogical to close it and open it in module of the form which is closed.:))
 
Actually, I figured this one out. I'd started another thread and posted the answer there.

Answer: You have to use the CreateGroupLevel method. It's in the help file. Easy peasy.


thx!

Q-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top