Can this be done?

W

Will

When designing Access forms, I like to experiment with variations on a given
layout. However, it can get old doing 'file/save as' again and again.
Oftentimes it would be convenient to be able to specify the form and the
number of copies that I would like and then have them created in a flash.
As such, what I am looking for is...

Have a macro or VB code that;

Prompts for the name of a form - then
Prompts for the number of copies to make - then
Creates x number of copies of the named form labled;

formname 1
formname 2
formname 3

and so forth.


Thanks,
Will
 
A

Anthos

This is best done in VBA Code.

Here is the code you are after.

Public Function CopyForms
Dim intNumber As Integer
Dim strForm As String
Dim intCurrentCopy As Integer
Dim strNewFormName As String
strForm = InputBox("Name of Form you want to copy", "Copy form")
intNumber = InputBox("How many copies would you like?", "Number of
Copies")

For intCurrentCopy = 1 To intNumber Step 1
strNewFormName = strForm & "_" & intCurrentCopy
DoCmd.CopyObject , strNewFormName, acForm, strForm
Next intCurrentCopy
End Function
 
W

Will

Thanks for the reply. I'm somewhat new to this. Where would I place the
code and how would I access it?

Regards
Will
 
A

Anthos

Being that this is a public function, you could place it in any new
module

However, if you wanted to create a single form with, with a single
button that did this, you would need to replace a couple of lines.
(Just the first and last, nothing else needs to be changed)

Copy and paste
Dim intNumber As Integer
Dim strForm As String
Dim intCurrentCopy As Integer
Dim strNewFormName As String
strForm = InputBox("Name of Form you want to copy", "Copy form")
intNumber = InputBox("How many copies would you like?", "Number
of
Copies")


For intCurrentCopy = 1 To intNumber Step 1
strNewFormName = strForm & "_" & intCurrentCopy
DoCmd.CopyObject , strNewFormName, acForm, strForm
Next intCurrentCopy

Into the function of a button on a form.
(Called an Event Procedure)

Hope this helps.

Regards
Anthony
 
Top