CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [Resolved] Limit the number of letters saved to record

Print topic Send  topic

Author Message
ckroon

Posts: 869
Posted: 06/26/2008, 2:10 PM

I have a field: 'firstname' that, when saved to the database, can only be the first initial.

Is there a simple way to do this?

Thanks!

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
mentecky

Posts: 321
Posted: 06/26/2008, 3:03 PM

Quote ckroon:
I have a field: 'firstname' that, when saved to the database, can only be the first initial.

Is there a simple way to do this?

Thanks!


Right click your "firstname" textbox in design mode. Select <INPUT> Properties. Set Width and Max Length to 1.

Rick
_________________
http://www.ccselite.com
View profile  Send private message
wkempees


Posts: 1679
Posted: 06/26/2008, 3:24 PM

OR,

click the textbox firstname in DesignMode.
In the properties, Events, OnValidate, Add Action: Require Maximum Length.
It not only helps you to remember/(see later) where you altered your textbox, it is a nice and CCS compliant way to do it, but far more important, It does Error Handling.
Your user will see the error message you supply and get used to it.
The simple beep will be overlooked and experienced as annoying.

Also when at a later state you allow for more initials you just up the value.

BTW, what is the length of that field in the Database?

Walter
*you could of course, also, let the user enter whatever they want and substring only the first character...... (bad practice)
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
ckroon

Posts: 869
Posted: 06/26/2008, 3:57 PM

Great responses both of you thanks!

But alas... its more complicated than that.

It's a hidden field and the value in it is populated with a CCDLookup

Guess I should have stated that in the beginning.

It's a great TIP thread so far though! :)

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
ckroon

Posts: 869
Posted: 06/26/2008, 4:29 PM

Got it!
I looked up 'substr' and used snippets of code I found in other threads.


In the labels Before Show event

First, set the value of the hidden field with a CCDLookup, then underneath it put this:

$Container->Label1->SetValue(substr($Container->Label1->GetValue(),0, 1));

Thanks all
:-D
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
wkempees


Posts: 1679
Posted: 06/26/2008, 5:00 PM


If your CCDLookup is like:
  
$Container->Label->SetValue( CCDLookup("firstname","table", id=....., DB........));  
Then this will work even better
  
$Container->Label->SetValue( CCDLookup("LEFT(firstname,1)","table", id=....., DB........));  

Walter


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.