Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Zip Code not properly displayed in database

Status
Not open for further replies.

breezett93

Technical User
Jun 24, 2015
128
US
Hello,

While reviewing the data (Data Session) that has been entered in this contacts database, I noticed that any zip codes with leading 0s did not display the zero(s).

However, while entering in data or finding records through the form, the leading 0s are all present and visible.

What do I need to change in the Table Designer (I'm assuming there) in order to have all five digits present in the database?

Thanks!
 
is your zipcode a numeric type field?

if so, that's why.

I would NOT make the zipcode a numeric, in case you have people or customers from Canada, where the zipcode is Alpha numeric.

Ez Logic
Michigan
 
I'm not sure what (Data Session) means in the way you're using it. Session is one of VFP's base classes, but it has no visible presence so you can't be looking at that. Every form has a DataSession (an instance of Session), but again there's no visual manifestation.

Be that as it may, the data is probably stored as a numeric value. (Or you're looking at it in Excel?) Zip codes shouldn't be numeric.

If that's not it, can you clarify just exactly you're looking at?
 
So I should change it from Numeric to Character?

@danfreeman: Window -> Data Session -> Open -> myTable -> Browse
That's how I was reviewing my data.
 
Ah, so you're using a Browse.

Zip codes should always be character. That will solve this problem (and many others down the line).

 
Also remember that AFTER you have changed the Zipcode field type from Numeric to Character, those Zipcodes with missing leading Zero's will need to be corrected.

REPLACE ALL Zips WITH PADL(ALLTRIM(Zips),5,'0') && Assuming 5 character Zipcodes and not something different

Good Luck,
JRB-Bldr
 
One of the dangers of using Excel with dbf's is it has a nasty habit of removing leading zero's. Then if you save you wreck things.
 
If you never use numeric fields except for numeric content, issues like this never occur.

Unfortunately Excel and most other spreadsheets always default to numeric whenever they encounter something that 'looks' numeric which makes it a pain when trying to integrate spreadsheet data into FoxPro. And in the spreadsheets I have worked with, there is no easy way to define cells, columns, and rows as 'text'.

mmerlinn


Poor people do not hire employees. If you soak the rich, who are you going to work for?

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top