Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop through textboxes on a form

Status
Not open for further replies.

jpl458

Technical User
Sep 30, 2009
337
0
0
US
Back at the trough on this AP. I have a form with a number of labled text boxes on it, and have a need to loop though them. I want to load data into them from vb application that queries a database. Found this bit of code on the web that is a clue, but I think isType is not a method:

Dim myCtrl As Control
Dim myTextbox as textbox
For Each myctrl In myForm.Controls
If isType(myctrl) = "textBox" then
set mytextbox = myctrl
mytextbox.Value= ""
end if
Next myctrl

Using ACCESS 2010, SQlServer DB

Any help would create joy.

Thanks in advance
jpl

 
Try something like:
Code:
    Dim myCtrl As Control
    Dim myTextbox As TextBox
    For Each myCtrl In Me.Controls
        If TypeName(myCtrl) = "textBox" Then
            Set myTextbox = myCtrl
            myTextbox.Value = ""
        End If
    Next myCtrl

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top