Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, November 22, 2024 
 
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 - Controls
Forum to discuss usage & tips for SalesLogix controls and other 3rd party ActiveX controls. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to Controls | New ThreadView:  Search:  
 Author  Thread: Make field mandatory
Darren Savery
Posts: 51
 
Make field mandatoryYour last visit to this thread was on 1/1/1970 12:00:00 AM
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?
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Make field mandatoryYour last visit to this thread was on 1/1/1970 12:00:00 AM
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
[Reply][Quote]
Darren Savery
Posts: 51
 
Re: Make field mandatoryYour last visit to this thread was on 1/1/1970 12:00:00 AM
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
[Reply][Quote]
susanr
Posts: 6
 
Re: Make field mandatoryYour last visit to this thread was on 1/1/1970 12:00:00 AM
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!
[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 © 2024 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): 11/22/2024 11:50:15 PM