The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
How to change the OK button behaviour
Posted: 01 Sep 06 11:47 PM
|
fiogf49gjkf0d When we click the OK button in the data form, it will save the data and hide the form.
Can I make it still in the original form after click the OK button? |
|
|
|
Re: How to change the OK button behaviour
Posted: 02 Sep 06 2:18 AM
|
fiogf49gjkf0d Change the button's "ModalResult" property to mrNone (or the Kind property to bkCustom). This will make it so that your own code can run behind the click on the button instead of closing and passing back result to the caller. Then in the code behind the button do whatever you need to do, then call:
ModalResult = mrOK ' -or- ModalResult = mrCancel
This will close the form and save any bound values (if you use mrOK). |
|
|
|
Re: How to change the OK button behaviour
Posted: 02 Sep 06 2:42 PM
|
fiogf49gjkf0d In my source code, I fist set the "Modal Result" property of OK button : mrNone, then in script:
if validInput = True Then Sender.ModalResult = mrOK else Sender.ModalResult = mrNone end if
The problem is I must click twice, then it can Save and close the form. Any idea? |
|
|
|
Re: How to change the OK button behaviour
Posted: 02 Sep 06 6:22 PM
|
fiogf49gjkf0d You're setting the ModalResult of Sender (which I assume is your button). You actually want to set the ModalResult of the Form itself. Get rid of the Sender from your code you posted and all should work fine (or replace "Sender" with your form name) |
|
|
|
Re: How to change the OK button behaviour
Posted: 02 Sep 06 6:34 PM
|
fiogf49gjkf0d To explain my last answer a bit more. The form's ModalResult property will cause the form to close and post and bound values to the database. When you set the ModalResult of a button, that is what it will set the form's ModaleResult when clicked. The button's ModalResult in itself means nothing, it is only used to set the form's ModalResult (when clicked). The Form's ModalResult property is the one that matters.
So the reason why you're form needs two clicks to close is because the first time you set the button's ModalResult property which has no effect until clicked again. If you just set the Form's ModalResult property it will happen right then, closing the form and saving the values.
make sense? |
|
|
| |
|