Invalid Qualifier


Posted by Duane Kennerson on December 05, 2001 5:36 PM

Here is the code:

Private Sub insertnewemployees()
'insert employee information into database

Dim a As Integer
Dim x As Integer
Dim aCount As Integer

x = Range("g2")
a = 1
aCount = 71

For a = 1 To aCount
Sheets("Stuff").Select

Range("b" & x) = TextBox & a.Text
a = a + 1
Range("c" & x) = TextBox & a.Text
a = a + 1
Range("d" & x) = TextBox & a.Text
a = a + 1
Range("e" & x) = TextBox & a.Text
a = a + 1
x = x + 1
Next a

End Sub

"TextBox & a.Text" is where I am having a problem, it says "a" is an invalid qualifier. Can anybody help???

Thanks in advance,
Duane

Posted by Colo on December 05, 2001 7:19 PM

Hi. I made a sample for you.
Before try this, please make 3 TextBoxes and rename "TB1","TB2","TB3".
And input Any word what you want.

Sub test()
Dim i As Integer
For i = 1 To 3
MsgBox ActiveSheet.TextBoxes("TB " & i).Text
Next
End Sub

Posted by Juan Pablo G. on December 05, 2001 7:20 PM

Your declaring a as an Integer, therefor, it's not an object. If not an object, then it doesn't have properties, methods and events. The .text is a property of some objects, like TextBoxes. I think what you're trying to do is insert the info from various textboxes (TextBox1,TextBox2, etc) into the worksheet, right ?

Then try this (Assuming this code is in the UserForm module, if not then change "Me" to the userform's name.)

Range("b" & x) = Me.Controls("TextBox" & a).Text

and repeat for the others.

Juan Pablo G.

Posted by Duane Kennerson on December 05, 2001 7:29 PM

You hit it right on the nose. Thanks!



Posted by Duane Kennerson on December 05, 2001 7:30 PM

Thanks for the help, its been solved!!!