11/22/2024 7:51:13 PM
|
|
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!
Forum to discuss usage & tips for SalesLogix controls and other 3rd party ActiveX controls. View the code of conduct for posting guidelines.
|
|
|
|
Make field mandatory
Posted: 25 Jul 06 10:36 AM
|
fiogf49gjkf0d Hi there,
Based on my previous plea for help, I have a couple of fields (DateTimePicker and txtQuoteNumber) that display if a value is chosen in a different field (in this case a picklist)
What I want to try and do is make one of these 'show if' fields mandatory...but only if it visible.
I have set the 'txtQuoteNumber' field as being mandatory and applied the following code to the form but it doesn't seem to work:
lblDateTimePicker.Visible = False DateTimePicker.Visible = False lblQuoteNumber.Visible = False txtQuoteNumber.Visible = False
Sub pckStageChange(Sender) If pckStage.Text = "Quoted" then lblDateTimePicker.Visible = True DateTimePicker.Visible = True DateTimePicker.Enabled = True lblQuoteNumber.Visible = True txtQuoteNumber.Visible = True txtQuoteNumber.Enabled = True Else DateTimePicker.Visible = False DateTimePicker.Enabled = False lblDateTimePicker.Visible = False lblQuoteNumber.Visible = False txtQuoteNumber.Visible = False txtQuoteNumber.Enabled = False End If End Sub
Can anyone rise to the challenge and help this newbie once again? |
|
|
|
Re: Make field mandatory
Posted: 26 Jul 06 1:11 AM
|
fiogf49gjkf0d Add an OnValidate event to your form, it's typically called AXFormValidate. By setting AXFormValidate = false, you keep the form from posting. My method below prompts once with a string built from unvalidated controls. You could modify it if you need to make sure a date matched a certain value for instance and it keeps everything in one place.
The DateTimeEdit control is better than the picker. It lets you have null values in the database where the picker does not.
Here's the example:
Function AXFormValidate(Sender) dim stringMissing dim booleanIsValid dim booleanResult dim integerResult On Error Resume Next booleanResult = false integerResult = 0 booleanIsValid = true if (pickListType.Text = "") then if (stringMissing = "") then stringMissing = "Type" else stringMissing = stringMissing & ", Type" end if booleanIsValid = false end if if (pickListStatus.Text = "") then if (stringMissing = "") then stringMissing = "Status" else stringMissing = stringMissing & ", Status" end if booleanIsValid = false end if if (not (booleanIsValid)) then integerResult = MsgBox(Application.Translator.Localize("The following items must be filled in: " & vbCRLF & stringMissing), vbYes, Application.Translator.Localize("Validation")) booleanResult = false else booleanResult = true end if AXFormValidate = booleanResult ErrorCheck(Application.Translator.Localize("AXFormValidate:")) On Error Goto 0 End Function
|
|
|
|
Re: Make field mandatory
Posted: 27 Jul 06 10:18 AM
|
fiogf49gjkf0d Hi Jeremy,
Many thanks for this. I'll try it out as soon as I get a chance. Hope I can get it to work!
Cheers,
Darren |
|
|
|
Re: Make field mandatory
Posted: 04 Oct 06 12:59 PM
|
fiogf49gjkf0d I've been working on the AXFormValidate for hours and just came across the answer right here... Thanks! |
|
|
|
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!
|
|
|
|
|
|
|
|