Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Sunday, July 6, 2025 
 
slxdeveloper.com Community Forums  
   
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!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Need Help With Form Validation Please
Bailey1
Posts: 57
 
Need Help With Form Validation PleaseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Oct 10 10:41 AM
I have added some custom code to the AXFormValidate function on the AccountDetails form, and it is working great except for this scenario. If a user enters bad data into my textbox (IUNumber) and then clicks on one of the other functions on the left nav bar (for ex., Contacts) or double clicks on a Contact to open the Contact form, the following happens:

1. Validation Error msgbox: Invalid IU # - Must be a 9 Digit Number
2. Script Error MsgBox:

An error occurred executing active form script (System:Account Detail).
Error calling method AXFormValidate

Cannot focus a disabled or invisible window.

When I then click on OK, I am taken to the Contact window. If the user then exits out of SalesLogix, or even returns back to the AccountDetail form, the bad data is saved. How can I keep the user from leaving the AccountDetail form before completing validation? Or at least prevent the bad data from being saved??

Here is my code:

IUNum = edtIUNumber.Text
If edtIUNumber.Enabled = True and not isnull(IUNum) and not isempty(IUNum) and not IUNum = "" then
If isnumeric(IUNum)= false or len(IUNum) < 9 then
msgbox "Invalid IU # - Must be a 9 Digit Number",vbOKOnly,"Validation Error"
edtIUNumber.SetFocus
AXFormValidate = False
End If
End If

Thanks!
[Reply][Quote]
Mike Spragg
Posts: 1226
Top 10 forum poster: 1226 posts
 
Re: Need Help With Form Validation PleaseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Oct 10 3:04 AM
Move you OnValidate to OnExit of the control edtIUNumber. The OnExit will process prior to the validate.
[Reply][Quote]
Bailey1
Posts: 57
 
Re: Need Help With Form Validation PleaseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Oct 10 9:32 AM
Thanks for the reply Mike, but unfortunately this did not work. I don't get the can't set focus error, but the bad data is saved when I click to another form, or when I move to another account.
[Reply][Quote]
Mike Spragg
Posts: 1226
Top 10 forum poster: 1226 posts
 
Re: Need Help With Form Validation PleaseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Oct 10 11:03 AM
What version are you on ??

Personally, I'd trap this way before here anyway - create a function (as below) and on the KeyPress event - put the function name in there (CheckForDecimal if you want dec points or CheckForInteger if not).

Sub CheckForInteger (Sender, ByRef Key)

' Check only for numeric values
' If ((Key < 48) or (Key > 57)) and not (Key = 8) and not (Key = 46) and not (Key = 44) then ' Allows "." and "," - but not for integer
If ((Key < 48) or (Key > 57)) and not (Key = 8) then
Key = 0
End If

End Sub

Sub CheckForDecimal (Sender, ByRef Key)

' Check only for numeric values
If ((Key < 48) or (Key > 57)) and not (Key = 8) and not (Key = 46) and not (Key = 44) and not (key = 45) then ' Allows "." and "," - but not for integer
' If ((Key < 48) or (Key > 57)) and not (Key = 8) then
Key = 0
End If

End Sub
[Reply][Quote]
Bailey1
Posts: 57
 
Re: Need Help With Form Validation PleaseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Oct 10 12:42 PM
We're on version 7.5.2

I added your suggested code above to the Key Press event, and that's great for enforcing the entering of numerics only - thanks! However, I also need to verify that the field length is = 9, and I do that in the AXFormValidate function. So I still have the same problem.
[Reply][Quote]
Mike Spragg
Posts: 1226
Top 10 forum poster: 1226 posts
 
Re: Need Help With Form Validation PleaseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Oct 10 3:12 AM
Try the OnBeforeRecordClose event instead ?
[Reply][Quote]
Bailey1
Posts: 57
 
Re: Need Help With Form Validation PleaseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Oct 10 9:56 AM
Do you mean the AXFormClose subroutine in the form script? If so, I added my code there, but it never got executed when I clicked on the left nav bar or double clicked on a contact.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Need Help With Form Validation PleaseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Oct 10 10:55 AM
Here is what is going on:

On the code, you are trying to set focus to the Control, but that may fail depending on what action you have chosen to navigate away from the View.

That failure is causing your code to never reach the "AXFormValidate = False", thus the validation function is not preventing the code from being saved.


My advice:

Move the AXFormValidate = False above the Set focus code.
Place an On Error Resume NExt above the SetFocus Code to prevent an error message when the focus cannot be set...


e.g.


If ValidationFails then
AxFormValidate = False

' Because the focus code may fail
On Error Resume Next
MsgBox "An error has ocurred"
myControl.SetFocus
End If


By adding the OnError Resume next, you allow the function to complete, and the return value to be passed correctly, thus preventing the value from being saved to the DB.
Now, you won't be able to retain the focus on the your View, but the data will not be saved.

[Reply][Quote]
Bailey1
Posts: 57
 
Re: Need Help With Form Validation PleaseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Oct 10 8:51 AM

Thank you so much Raul.  I tried your suggestion, and it works great !!!

[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Need Help With Form Validation PleaseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Oct 10 9:36 AM

Glad to be able to help.


As soon as I read your original Post I quickly realized that the Code was aborting on the Error, thus the Failure on the Validation was never being reached.


 

[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 7/6/2025 4:04:08 AM