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
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