Solved Createcontrol cannot create Label or Textbox at Header Section !!! (1 Viewer)

Shananarocks

New member
Local time
Today, 13:46
Joined
Feb 25, 2020
Messages
4
Good Afternoon, I am using a subroutine to create a new form and also a label at the "Header" section. The routine below works only if I use the default to create the label control in the Details section. However, it will shows an error if I try to add the label control to the "Header" section ........ "Run-time error :2148" The number you used to refer to the form or report section is invalid"

My codes are as follows:

Private Sub CreateLabelControl_Click()

Dim frm As Form
Dim ctlLabel As Control

Set frm = CreateForm()

Set ctlText = CreateControl(frm.Name, acLabel, , "", "", 1000, 300, 4000, 300) 'This works fine and can create label or textboxes at the default Details Section!!!
' Set ctlText = CreateControl(frm.Name, acLabel, acHeader, "", "", 1000, 300, 4000, 300) 'This result in error 2148 when set to acHeader although it is an allowable option

ctlText.Caption = "Testing Testing"

DoCmd.Restore
DoCmd.RunCommand acCmdFormView

End Sub

Appreciate any advice or help. Thanks ! Mikey
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:46
Joined
May 7, 2009
Messages
19,169
maybe this one has the answer (show the header).


Code:
...
Set frm = CreateForm()
DoCmd.RunCommand acCmdFormHdrFtr
...
 

Shananarocks

New member
Local time
Today, 13:46
Joined
Feb 25, 2020
Messages
4
Excellent solution arnelgp !!! Why didn't I see this "acCmdFormHdrFtr" when I was scrolling the docmd.runcommand
Anyway, I also came up with another solution which is to create a form with the header "evoked" and use it as a template in the
Set frm = CreateForm(, "MyForm") where "MyForm" is a the template upon which the new forms will draw its attributes like colors, width etc
Appreciate your solution too.

Best Regards, Mikey


maybe this one has the answer (show the header).


Code:
...
Set frm = CreateForm()
DoCmd.RunCommand acCmdFormHdrFtr
...
 

Users who are viewing this thread

Top Bottom