Format Empty field on form (1 Viewer)

tucker61

Registered User.
Local time
Yesterday, 16:50
Joined
Jan 13, 2008
Messages
265
I have the below code which works - but i wanted to condense it. due to the number of controls that i need to check.

Code:
If IsNull(CboxSite) Then
CboxSite.BackColor = vbRed
CboxSite.SetFocus
MsgBox ("Please complete the missing Fields.")
Exit Sub
Else
CboxSite.BackColor = vbWhite
End If

So i have pulled together this code to check each Control,

Dim ctl As Control
For Each ctl In Me.Controls
Select Case TypeName(ctl)
Case "ComboBox", "TextBox"
If ctl.Tag = "Req" Then
If IsNull(ctl) Then
ctl.backcolour = vbRed
ctl.SetFocus
MsgBox ("Please complete the missing Fields.")
Exit Sub
End If
End If
End Select
Next

I am getting a error message "438 - Object does not support this property or method."
I get this message if any of my Required fields that are null.

Is it that i have got my select case in the wrong position ?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:50
Joined
May 7, 2009
Messages
14,556
use BackColor instead of BackColour.
 

Users who are viewing this thread

Top Bottom