BackStyle property (1 Viewer)

MikeLeBen

Still struggling
Local time
Today, 14:17
Joined
Feb 10, 2011
Messages
187
I have this button in a form that's used to go to a new record so that user can fill various textboxes.

These textboxes are by default transparent, so to look non-editable. Therefore I want them to become Normal as the user clicks on that button.

On the _click event I used the following code

Code:
Dim txt As TextBox

For Each txt In Me.Form
txt.BackStyle = Normal
Next txt

but I get a type mismatch error. Any ideas?
 

MikeLeBen

Still struggling
Local time
Today, 14:17
Joined
Feb 10, 2011
Messages
187
I did, and got the same error:

Type mismatch on line -> For Each txt In Me.Form
 

boblarson

Smeghead
Local time
Today, 05:17
Joined
Jan 12, 2001
Messages
32,059
You will likely need to do it this way:
Code:
Dim ctl As Control
For Each ctl In Me.Controls
    If ctl.ControlType = acTextBox Then
        ctl.BackStyle = 1
    End If
    
Next
Tested and works.
 

MikeLeBen

Still struggling
Local time
Today, 14:17
Joined
Feb 10, 2011
Messages
187
You will likely need to do it this way:
Code:
Dim ctl As Control
For Each ctl In Me.Controls
    If ctl.ControlType = acTextBox Then
        ctl.BackStyle = 1
    End If
    
Next
Tested and works.

beautiful, cheers
 

Users who are viewing this thread

Top Bottom