Cycle through all TEXTbox controls

1jet

Registered User.
Local time
Tomorrow, 06:53
Joined
Sep 15, 2008
Messages
117
Hi all,

The below thread shows how to use a FOR EACH statement to go through each control of a form.
http://www.access-programmers.co.uk/forums/showthread.php?t=157256&highlight=control

I wanted to use this idea to CLEAR all TEXT BOXES in my form.

So far my code is as follows.

Code:
Dim ctrl As control

For Each ctrl In Forms("frmNewEmployee")
    [COLOR=Red]Set ctrl.Value = ""[/COLOR]
Next
When I run the function the line in red gives the error "object required."
I just learnt that this function will cycle through labels, as well as combo and text boxes.

Is there any way I can cycle through just text boxes?
 
Code:
Dim ctrl As control

For Each ctrl In Forms("frmNewEmployee").Controls
    If ctrl.ControlType = acTextBox Then
       Set ctrl.Value = ""
    End If
Next
 
Cheers bob!
 

Users who are viewing this thread

Back
Top Bottom