Custom Function

  • Thread starter Thread starter Abdul Shakeel
  • Start date Start date
A

Abdul Shakeel

Hi All,

I've a form in which I've several text Boxes some of which are must to be
filled by the user I just want that if user dont put data in any required
textbox a custom massage appears asking for filling the data.

for this purpose I want that I make custom function so I could call this
function anywhere I want this validation.
 
The best place to ensure a value is in a required field is in the Form
Current event. The basic structure there is:

Private Sub Form_Current(Cancel As Integer)

If <<some condition fails>> Then
MsgBox "Not Valid"
Cancel = True
End If

You can do it specifically for each control you want to validate:

If IsNull(Me.txtFilingDate) Then
MsgBox "Filing Date Is Required"
Cancel = True
Me.txtFilingDate.SetFocus
End If

You could write a generic function you can call from anywhere, but
generally, the requirements for each control are unique enough that such a
function may not be that useful.
 
I'm not seeing the problem here. Cancel is an Integer in forms (for no
reason I understand...I think it's because historically, there was no Boolean).


Rob
 
Robert Morley said:
I'm not seeing the problem here. Cancel is an Integer in forms (for no
reason I understand...I think it's because historically, there was no
Boolean).


Rob

Hi Rob

So you missed it too <g>.
The Form_Current event doesn't have a Cancel parameter. He'll know as soon
as he re-reads what I back-quoted. I think he probably means
Form_BeforeUpdate.
 
Hi Rob
So you missed it too <g>.
The Form_Current event doesn't have a Cancel parameter. He'll know as soon
as he re-reads what I back-quoted. I think he probably means
Form_BeforeUpdate.

D'oh!


Rob
 
Back
Top