Clearing Textboxes

edp1959

Registered User.
Local time
Today, 18:22
Joined
Aug 24, 2003
Messages
23
Help - This should be simple

I'm using this code to clear unbound text boxes on my form. I keep getting an error message "Object doesn't support this property or method". I'm using this same code on other forms and it works fine. What am I missing? I'm using Access 2000.

Dim ctl As Control

Set dbs = CurrentDB


For Each ctl In Me.Controls
If ctl.Tag = "A" Then
ctl = Null
End If
Next
 
Don' forget that everything you put on the form is a control...even labels.

Code:
Dim ctl As Control

For Each ctl In Me
    If ctl.ControlType = acTextbox Then
        If ctl.Tag = "A" Then ctl = Null
    End If
Next

Also, this line (Set dbs = CurrentDB) would have caused an error if you were using a default A2000 database with its DAO reference unchecked).
 
Thanks, this worked fine. I wonder why my previous code worked on other forms in the same database.
 

Users who are viewing this thread

Back
Top Bottom