Am Dienstag, den 01.05.2007, 16:30 +0200 schrieb Helge Kraak:
> Hi,
>
> maybe somebody of you can assist me with my attempt to have a working
> veto function for dataset changes in a form. In case a certain entry
> in a form doesn't match a correct value I want to intercept the user
> from switching to next dataset. I found a script from Frank Schönheit
> which doesn't work but I don't know what is wrong with it:
>
> Function approve( Source as Object ) as Boolean
> If ( val( Source.Source.Text ) > 10 ) Or ( val( Source.Source.Text )
> < 1 ) Then
> MsgBox "too large!"
> approve = FALSE
> End If
> approve = TRUE
> End Function
This is a logical error made by Java programmers. ;)
Setting the value of the function does not cause the program flow to
stop and exit but goes on, running over the second assignment to
approve. This way approve always yields the value TRUE.
Change it this way and it works:
Function approve( Source as Object ) as Boolean
If ( val( Source.Source.Text ) > 10 ) Or ( val( Source.Source.Text ) <
1 ) Then
MsgBox "too large!"
approve = FALSE
else
approve = TRUE
End If
End Function
Or insert a line saying "exit function" after setting approve to FALSE
to make BASIC behave like Java.
Have fun,
Marc
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]