Mikoshiba-Kyu
Mikoshiba-Kyu

Reputation: 23

Can I create a form with a form header and footer using VBA?

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?

Upvotes: 1

Views: 775

Answers (1)

Andy Wynn
Andy Wynn

Reputation: 1273

You could always try:

DoCmd.RunCommand acCmdFormHdrFtr

Upvotes: 3

Related Questions