Function return value

P

Phil

Hi,

I have a form with a lot of command buttons on it. Most of the code in the
buttons perform the same error checking (with diffent fields) in the on click
code. I want to replace the code with a call to a function which will do the
checking and return a value based on the results. I would like to have the
on click event for each command button to start with this type of code:

If (CheckForErrors(fieldList........)) then goto exit_command_click

How do I get the function to return a value? I want the value to be a 1 if
error are found and a 0 if no errors. I know this must be simple, but I
can't figure it out.....

Thanks,
 
R

Rick Brandt

Hi,

I have a form with a lot of command buttons on it. Most of the code in the
buttons perform the same error checking (with diffent fields) in the on click
code. I want to replace the code with a call to a function which will do the
checking and return a value based on the results. I would like to have the
on click event for each command button to start with this type of code:

If (CheckForErrors(fieldList........)) then goto exit_command_click

How do I get the function to return a value? I want the value to be a 1 if
error are found and a 0 if no errors. I know this must be simple, but I
can't figure it out.....

Within the function's code you have to set the name of the function to a
value.

EX:

Function TodayIsSunday() As Boolean

If Format(Date, "dddd") = "Sunday" Then
TodayIsSunday = True
Else
TodayIsSunday = False
End If

End Function

(the else is rundant as False will be the default)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top