Ref. 20 textboxes on a form numerically

bob.walker

Member
Joined
May 17, 2005
Messages
18
Programming Experience
3-5
One a form I have 20 textboxes. How can I put the save in a loop.

for x = 1 to 20
sStmt = "update textlist set "

****************
sStmt += " document = '"+??(textbox_x)??+"'"
****************

sStmt += " where item = "+item_no

Sqlexe(sStmt, oConn)
next
 
Last edited:
Hey bob,

You can use Me.Controls / Panel.Controls / GroupBox.Controls to access all the controls in the form and check the Name property of the textboxes to establish the order. ie.

VB.NET:
dim tempTextBox as TextBox
 
for each tempTextBox in Me.Controls
 
sStmt += " document = '" + tempTextBox.Text + "'"
 
Next

Hope this helps.
 
closer

On the first time through it after the assign statement, it goes to "next" then straight to "Catch" statement with the error saying "Specified cast is not valid."

I did get it to work with
For x = 0 To Me.tabPAGE1.Controls.Count - 1

sStmt = " document = '" +
Me.tabPAGE1.Controls(x).Text + "'"

Next

This goes through all controls, but I can work from there. Thanks
 
Last edited:
Back
Top