E
edamron
I need to dynamically build a form that has a frame within another
frame but the code blows up with a message telling me that the control
failed to be added. The code looks like this:
Private Sub AllowAccept(ByRef fraAg As Control, ByRef fraOrd As
Control)
Dim ochkInjury As Control
Dim oLabel1 As Control
Dim otxtInjuryDate As Control
Dim ochkDiagnoses As Control
Dim ofraWasWere As Control
Set ochkInjury = fraAg.Controls.Add("Forms.CheckBox.1",
"chkInjury", True)
With ochkInjury
.Caption = "The claimant sustained an injury while in the
course..."
.Left = 6
.Height = 19.5
.Top = 12
.Width = 269.25
End With
Set oLabel1 = fraAg.Controls.Add("Forms.Label.1", "Label1", True)
With oLabel1
.Caption = "Injury Date:"
.Left = 18
.Height = 18
.Top = 42
.Width = 60
End With
Set otxtInjuryDate = fraAg.Controls.Add("Forms.Textbox.1",
"txtInjuryDate", True)
With otxtInjuryDate
.Text = ""
.Left = 78
.Height = 18
.Top = 42
.Width = 150
End With
Set ochkDiagnoses = fraAg.Controls.Add("Forms.Checkbox.1",
"chkDiagnoses", True)
With ochkDiagnoses
.Caption = "The claimant's condition diagnosed as"
.Left = 6
.Height = 19.5
.Top = 72
.Width = 267.75
End With
Set ofraWasWere = fraAg.Controls.Add("Forms.Frame.1",
"fraWasWere", True) <<<< It blows up here.
With ofraWasWere
.Caption = ""
.Left = 12
.Height = 66
.Top = 126
.Width = 72
End With
End Sub
What am I doing wrong? Thanks.
frame but the code blows up with a message telling me that the control
failed to be added. The code looks like this:
Private Sub AllowAccept(ByRef fraAg As Control, ByRef fraOrd As
Control)
Dim ochkInjury As Control
Dim oLabel1 As Control
Dim otxtInjuryDate As Control
Dim ochkDiagnoses As Control
Dim ofraWasWere As Control
Set ochkInjury = fraAg.Controls.Add("Forms.CheckBox.1",
"chkInjury", True)
With ochkInjury
.Caption = "The claimant sustained an injury while in the
course..."
.Left = 6
.Height = 19.5
.Top = 12
.Width = 269.25
End With
Set oLabel1 = fraAg.Controls.Add("Forms.Label.1", "Label1", True)
With oLabel1
.Caption = "Injury Date:"
.Left = 18
.Height = 18
.Top = 42
.Width = 60
End With
Set otxtInjuryDate = fraAg.Controls.Add("Forms.Textbox.1",
"txtInjuryDate", True)
With otxtInjuryDate
.Text = ""
.Left = 78
.Height = 18
.Top = 42
.Width = 150
End With
Set ochkDiagnoses = fraAg.Controls.Add("Forms.Checkbox.1",
"chkDiagnoses", True)
With ochkDiagnoses
.Caption = "The claimant's condition diagnosed as"
.Left = 6
.Height = 19.5
.Top = 72
.Width = 267.75
End With
Set ofraWasWere = fraAg.Controls.Add("Forms.Frame.1",
"fraWasWere", True) <<<< It blows up here.
With ofraWasWere
.Caption = ""
.Left = 12
.Height = 66
.Top = 126
.Width = 72
End With
End Sub
What am I doing wrong? Thanks.