CreateForm from template does not seem to work properly

D

Dale Fye

I have a form (frm_Graph_Template) that contains a bunch of controls.

I would like to copy and modify the form programmatically. I assumed that
the CreateForm( , template) function would copy the form and all the controls
on it, but that does not appear to be the case. It copies the form, but none
of the controls.

Is this the intended purpose of this Method? If so, I guess I will have to
write a loop that looks through all of the controls on the original and
duplicates them in the copy using the CreateControl method.

Dale
 
L

Linq Adams via AccessMonster.com

From Access Help:

The template determines which sections a form or report will have and defines
each section's dimensions. The template also contains all the default
property settings for the form or report and its sections and controls...
However, a template doesn't create controls on a new form or report."

Linq

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
D

Dale Fye

Linq,

Where did you find this definition? I'm using 2003. When I clicked on
Help->Microsoft Office Access Help, and typed in CreateForm. It came back
with a hyperlink to a microsoft help page that provides:

"The CreateForm method creates a form and returns a Form object."

When I highlight "CreateForm" in my code, and press F1, I get the VB help
screen which states the exact same "definition". I didn't find the
explanation you provided in any of the locations I searched.

Not that it was a problem, I just created a loop to loop through the
controls and used CreateControls. I just kind of assumed that if I were
going to create a method that used another form as the template, it would at
least provide me with the option to duplicate all of the controls on the form.

Dale

email address is invalid
Please reply to newsgroup only.
 
S

Stuart McCall

I would like to copy and modify the form programmatically.

You could use CopyObject for this purpose:

DoCmd.CopyObject , "MyNewForm", acForm, "MyOriginalForm"
 
D

Dale Fye

Thanks, Stuart.

I knew there was a DeleteObject method, don't know why I didn't think about
there being a CopyObject.

Dale

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 

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