Home > Back-end >  Can I create a form with a form header and footer using VBA?
Can I create a form with a form header and footer using VBA?

Time:12-17

I want to create forms automatically in MS-Access using VBA. If it is a simple form, I could create it with the following code.

Dim newForm As Form: Set newForm = Application.CreateForm

However, a form created in this way does not retain the header and footer.

Debug.Print newForm.Section(acHeader).Name

>> Error 2462

If you open it in Design View and display the form header and footer manually from the menu, the above code will succeed from then on.

Debug.Print newForm.Section(acHeader).Name

>> FormHeader

Is it possible to add form headers and footers using only VBA?

CodePudding user response:

You could always try:

DoCmd.RunCommand acCmdFormHdrFtr
  • Related