Normal Topic ZipCode Formatting & Auto Filling City and State (Read 4304 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
ZipCode Formatting & Auto Filling City and State
Feb 26th, 2004 at 9:13pm
Print Post Print Post  
This Code Goes in Zip on Element Exit Event. It will let you enter either 5 or 9 digits and then format it accordingly. After putting the zipCode, it will also pick up City and State from ZipCode.db which came to you with Sesame in Sample folder. Zipcode.db is very big database, just enter one lookup in the Global Code of your database, this will reduce the lookup time significantly.

IF @LEN(ZIP) <> 5  and @LEN(ZIP) <> 9 THEN
     {
           @MSGbox("ENTER PROPER ZIP CODE", "", "");
           GOTO ZIP
     }


If @len(@num(zip)) = 9 then
     zip = @left (zip, 5) + "-" + @right (zip, 4)


City = @XLookup("c:\Sesame\Data\Samples\ZipCode.db", @left (zip, 5), "Zip Code", "City")
State = @XLookup("c:\Sesame\Data\Samples\ZipCode.db", @left (zip, 5), "Zip Code", "State")  

==========
in GLOBAL CODE:

var str as string

str = @XLookup("c:\Sesame\Data\Samples\ZipCode.db", "Hiram", "xxxxxCity", "Zip Code")
  
Back to top
 
IP Logged
 
FSGROUP
Full Member
***
Offline


No personal text

Posts: 179
Location: Edmonton, Alberta, Canada
Joined: Jan 14th, 2004
Re: ZipCode Formatting & Auto Filling City and Sta
Reply #1 - Mar 3rd, 2004 at 7:08pm
Print Post Print Post  
I'm having trouble using goto.

What difference does it make whether I do error checking in On Element Change or On Element Exit?

I have a LE named FirstName and this is the code:

if @Len(@Num(FirstName)) > 0 and FirstName <> "" then
{

@MsgBox("Error: First Name cannot contain digits.","","")
goto FirstName
}

If I put this code inside On Element Change and I enter a first name with digits in it, I receive the error message 3 times repeatedly and then I return to the FirstName LE. However, if I put the code inside On Element Exit, I get the error message once and then I arrive in another LE (named LastName).

What gets weirder is that if i change "goto FirstName" to "goto Company" in Element Exit, where Company is another LE, I will arrive in the correct LE?

Why am I receiving 3 error messages w/ On Element Change when the value of the LE has not changed after I get the first error message?

Thanx
  
Back to top
IP Logged
 
Forum Admin
YaBB Administrator
*****
Offline



Posts: 44
Joined: Jan 1st, 2001
Re: ZipCode Formatting & Auto Filling City and Sta
Reply #2 - Mar 3rd, 2004 at 7:23pm
Print Post Print Post  
FSGROUP,

In the interest of not muddying up the Programming Examples, could you please start a thread in the General area with your GoTo questions? In general, only comments pertaining very specifically to the posted code should be posted in this Board.
  

-----&&Erika Yoxall&&Forum Administrator
Back to top
 
IP Logged
 
FSGROUP
Full Member
***
Offline


No personal text

Posts: 179
Location: Edmonton, Alberta, Canada
Joined: Jan 14th, 2004
Re: ZipCode Formatting & Auto Filling City and Sta
Reply #3 - Mar 3rd, 2004 at 7:34pm
Print Post Print Post  
sorry, i just did a search, found a related thread and replied to it. i didn't see that it was in the programming examples
  
Back to top
IP Logged