Hi there,
This could be a easy one for a VBA "savvy"..
I have the following piece of validation code(part of a function) that returns True/False based on whether the required data is filled:
For Each ctl In Controls
If IsNull(ctl) And (ctl.Tag = "*") Then
ValidateRequiredFields = False
ctl.SetFocus 'Set focus to the control
Me.btnMissingData.Visible = True
Me.imgYellowbck.Visible = True
Exit Function
Else
ValidateRequiredFields = True
Me.btnMissingData.Visible = False
Me.imgYellowbck.Visible = False
End If
Next ctl
Now my issue is, I have added five new fields that are also mandatory. However, each one of them is mandatory, depending on the identity of the user or which group they belong to.(The db captures the windows log in and looks up the group for the user).
So only one of these 5 fields is mandatory at a time... For example if usergroup = HR then DateHR is mandatory, etc...
How can incorporate this nicely in my piece of code above without adding long messy code just for the 5 new fields..
I would really appreciate any help..
Thanks,
Elias.
This could be a easy one for a VBA "savvy"..
I have the following piece of validation code(part of a function) that returns True/False based on whether the required data is filled:
For Each ctl In Controls
If IsNull(ctl) And (ctl.Tag = "*") Then
ValidateRequiredFields = False
ctl.SetFocus 'Set focus to the control
Me.btnMissingData.Visible = True
Me.imgYellowbck.Visible = True
Exit Function
Else
ValidateRequiredFields = True
Me.btnMissingData.Visible = False
Me.imgYellowbck.Visible = False
End If
Next ctl
Now my issue is, I have added five new fields that are also mandatory. However, each one of them is mandatory, depending on the identity of the user or which group they belong to.(The db captures the windows log in and looks up the group for the user).
So only one of these 5 fields is mandatory at a time... For example if usergroup = HR then DateHR is mandatory, etc...
How can incorporate this nicely in my piece of code above without adding long messy code just for the 5 new fields..
I would really appreciate any help..
Thanks,
Elias.