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