StormbringerX
Programmer
Hello everyone, it's been a while.
My problem is this: I'm adding textboxes to a form at runtime. Using the following code:
Private Sub AddBoxesForTaxes()
Dim intNumTaxes As Integer
Dim intLoopit As Integer
Let intNumTaxes = 10
Dim intTop As Integer
Dim intLeft As Integer
Dim intHeight As Integer
intTop = 360
intHeight = 285
intLeft = 120
Dim strTextBoxName As String
For intLoopit = 1 To intNumTaxes
strTextBoxName = "frmPetitionRefundtxtbox" & intLoopit
frmPetitionRefund.Controls.Add "VB.TextBox", strTextBoxName, Frame(2)
MsgBox strTextBoxName
With frmPetitionRefund.Controls(strTextBoxName)
.Top = intTop
.Left = intLeft
.Height = intHeight
.Visible = True
.Text = intLoopit ' So I can see that it's doing something
End With
intTop = intTop + 480
Next
'frmPetitionRefundtxtbox2.Text = "This is 2"
End Sub
The textboxes are added without any problem and display correctly. The msgbox is in there just so that I could be sure that it was adding them using the names that I wanted, which it is.
However anytime I try to pull the form to the screen with a line of code that changes any of the textboxes properties, (see the last remarked line where I attempted to set the text property) I get the error 'Compile Error: Variable not defined' The error does not occur at the time I try to access the text box properties, it is displayed as soon as I try to pull the form up.
It displays properly as long as I do not try to access any of the properties of the textboxes through code.
I searched the FAQ's and the forum but found nothing that would help me out.
Any suggestions will be welcomed and appreciated.
Dave
My problem is this: I'm adding textboxes to a form at runtime. Using the following code:
Private Sub AddBoxesForTaxes()
Dim intNumTaxes As Integer
Dim intLoopit As Integer
Let intNumTaxes = 10
Dim intTop As Integer
Dim intLeft As Integer
Dim intHeight As Integer
intTop = 360
intHeight = 285
intLeft = 120
Dim strTextBoxName As String
For intLoopit = 1 To intNumTaxes
strTextBoxName = "frmPetitionRefundtxtbox" & intLoopit
frmPetitionRefund.Controls.Add "VB.TextBox", strTextBoxName, Frame(2)
MsgBox strTextBoxName
With frmPetitionRefund.Controls(strTextBoxName)
.Top = intTop
.Left = intLeft
.Height = intHeight
.Visible = True
.Text = intLoopit ' So I can see that it's doing something
End With
intTop = intTop + 480
Next
'frmPetitionRefundtxtbox2.Text = "This is 2"
End Sub
The textboxes are added without any problem and display correctly. The msgbox is in there just so that I could be sure that it was adding them using the names that I wanted, which it is.
However anytime I try to pull the form to the screen with a line of code that changes any of the textboxes properties, (see the last remarked line where I attempted to set the text property) I get the error 'Compile Error: Variable not defined' The error does not occur at the time I try to access the text box properties, it is displayed as soon as I try to pull the form up.
It displays properly as long as I do not try to access any of the properties of the textboxes through code.
I searched the FAQ's and the forum but found nothing that would help me out.
Any suggestions will be welcomed and appreciated.
Dave