Good Morning, I have written the two functions below but they cant be used together, one is a validation function the other is a clearing function, if I place a c and v in the tag proprty box they are both ignored I tried changing one to I as Integer and placing a 1 in the tag box but did not work.
Can some one see how to either alter one of them or call them differently so they can work together, Thanks
Function ClearAll(c As String, f As Form)
Dim ctl As Control
For Each ctl In f.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acCheckBox
If ctl.ControlSource = "" And ctl.Tag <> "c" Then
ctl.Value = Null
End If
Case Else
End Select
Next ctl
End Function
And
Function Validate("v" As String, frm As Form)
Dim nl As String, ctl As Control
nl = vbNewLine & vbNewLine
For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acCheckBox
If Trim(ctl & "") = "" And ctl.Tag = "v" Then
Msg = "Data Required for '" & ctl.Controls(0).Caption & "'" & nl & _
"Required Data!" & nl & "Please enter the data and try again ... "
Style = vbInformation + vbOKOnly
Title = "Required Data..."
MsgBox Msg, Style, Title
ctl.SetFocus
Cancel = True
End If
Case Else
End Select
Next ctl
End Function
Can some one see how to either alter one of them or call them differently so they can work together, Thanks
Function ClearAll(c As String, f As Form)
Dim ctl As Control
For Each ctl In f.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acCheckBox
If ctl.ControlSource = "" And ctl.Tag <> "c" Then
ctl.Value = Null
End If
Case Else
End Select
Next ctl
End Function
And
Function Validate("v" As String, frm As Form)
Dim nl As String, ctl As Control
nl = vbNewLine & vbNewLine
For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acCheckBox
If Trim(ctl & "") = "" And ctl.Tag = "v" Then
Msg = "Data Required for '" & ctl.Controls(0).Caption & "'" & nl & _
"Required Data!" & nl & "Please enter the data and try again ... "
Style = vbInformation + vbOKOnly
Title = "Required Data..."
MsgBox Msg, Style, Title
ctl.SetFocus
Cancel = True
End If
Case Else
End Select
Next ctl
End Function