Tupacmoche
Registered User.
- Local time
- Today, 09:57
- Joined
- Apr 28, 2008
- Messages
- 291
Hi VBA Masters,
I have the following code that I adopted from the web. It is cool because the loop checks any control whose tag is set to 'v'. It returns the name of the offending control and puts the focus on it so the user can fill it in. The issue that I have is the call to the function. After looping through any offending control the button that launches it simple does nothing when clicked. Can anyone see why?
I have the following code that I adopted from the web. It is cool because the loop checks any control whose tag is set to 'v'. It returns the name of the offending control and puts the focus on it so the user can fill it in. The issue that I have is the call to the function. After looping through any offending control the button that launches it simple does nothing when clicked. Can anyone see why?
Code:
'***CODE TO VALIDATE DONOR FORM REQUIRED FIELDS**********************************************************'
'***This function checks Donor Name, Transmittal type, Payment Method, Gift Matched, and Pre-deposited **'
If ValDonorFrm() = 0 Then
Exit Sub
Else
Exit Sub
End If
'********************************************************************************************************'
Public Function ValDonorFrm()
Dim bCheck As Boolean
Dim ctl As Control
For Each ctl In Me.Detail.Controls
With ctl
If .Tag = "v" Then
If IsNull(.Value) Then
MsgBox ctl.Name & " is empty, this is a required field!", vbOKOnly, "Required Field"
ctl.SetFocus
Cancel = True
Exit Function
End If
End If
End With
Next ctl
End Function