Create and Save New Form

gnaga

New member
Local time
Today, 15:53
Joined
May 12, 2005
Messages
7
Hi,

I am very new to MS Access but having exposure to VB and Excel VBA.
I am trying to create new form using code. Form is created but I could not save the form in the name I wanted. It is saving in the name of Form1. How to write code to save the newly created form in the name we give?

TIA

GNaga
 
Hey:
Use the Rename method of the DoCmd object...

Code:
Sub CreateAndRenameForm(newName As String)
   Dim frm As Form
   Dim oldName As String
   
[COLOR=Green]   'create new form, retain its name, and save it
[/COLOR]   Set frm = CreateForm()
   oldName = frm.Name
   DoCmd.Close acForm, oldName, acSaveYes
   
[COLOR=Green]   'rename saved form
[/COLOR]   DoCmd.Rename newName, acForm, oldName

End Sub
 
Lagbolt thank you very much for your kind help to me.

Thanks again

GNaga
 

Users who are viewing this thread

Back
Top Bottom