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!
|
|
Validation on a manage form
Posted: 02 May 08 10:28 AM
|
I have a manage form that has several required fields on it. The form validate wasn't working correctly so I changed the Button Kind to bkCustom and set the modal result to mrNone. On the button click event I added the line Appliaction.BasicFunctions.CloseCurrentView False as the last line of code. That code fires after the values are written to the database. What I need to do is stop the program from writing changes to the database after the user clicks OK on the message box that displays if there is a blank field that is required. |
|
|
|
Re: Validation on a manage form
Posted: 02 May 08 11:03 AM
|
IIRC validation doesn't fire the same for non-bound forms. What I usually do is script it. Check the required controls (which you can do generically as well if needed by flagging the required ones and looping through the controls) and then stop execution if the form does not validate. |
|
|
|
Re: Validation on a manage form
Posted: 02 May 08 11:22 AM
|
Thanks Ryan....
This is the validation code that is firing on the button click event: If dteStartDate.Text = "" Then msgbox("You must enter a Start Date."), 64, "Add/Edit Class" dteStartDate.SetFocus End If Exit Sub
If dteEndDate.Text = "" Then msgbox("You must enter an End Date."), 64, "Add/Edit Class" dteEndDate.SetFocus End If Exit Sub
This in now stopping when clicking the Ok button on the message box, but after entering data in the fields and clicking the Ok button the program does not continue on to add or update the database.
Any suggestions?
|
|
|
|
Re: Validation on a manage form
Posted: 02 May 08 11:36 AM
|
That is because your "Exit Sub" statements are *outside* of your IF blocks. Move them inside the IF blocks and all will be fine (you only want to exit the sub if validation fails). |
|
|
|
Re: Validation on a manage form
Posted: 02 May 08 11:44 AM
|
My bad, I didn't even pay any attention to that. After making the chages it is working just like it is firing on a data form.
Thanks Ryan!!! |
|
|
|
Re: Validation on a manage form
Posted: 02 May 08 4:24 PM
|
For future reference, I don't know if you used this or not, AXFormCloseQuery (OnCloseQuery on the form events tab) is the event you want to use for manage form validation. This is the event that allows you to prevent the form from closing and still allows you to use the default and cancel buttons for modalresults.
|
|
|
|