I have a form called 'Main - Form'. This form has a middle section that will display another form which the user selects from a listbox (which is on the 'Main - Form'). Let's say the user selects the form 'account'
I need to create a function that checks each control on the 'account' form to see if it is empty. I use the controls' tag option to see what the requirement is. Based on the tag value, the background of the field should be red (tag = M) or orange (tag = O) if the field is empty.
On the account form in the Private Sub Form_Current() section I want to pass the the correct name of the account form to this funtion:
Public Sub CheckFields(strForm As String)
'Check if tag of field contains a value B,M,O or nothing and color background based on that value.
Dim ctl As Control
For Each ctl In Forms![Main - Form]![strForm].Form!Controls
If ctl.Tag = "M" and ctl.value = "" Then
Debug.Print ctl.name
ctl.Tag.BackColor = vbRed
End If
Next ctl
Somehow I can't get this to work.