A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Validation for partial addresses



 
 
Thread Tools Display Modes
  #1  
Old June 8th, 2009, 09:45 PM posted to microsoft.public.access
Gabe
external usenet poster
 
Posts: 83
Default Validation for partial addresses

Hello,

I was wondering if anyone might know the code to use for validating partial
addresses? The addresses in my table should look like this: Salem, OR 97301.
However, some users are putting bad data in there like: sAlem or 9730. How
can I stop this from happening?

Thanks,
~Gabe
  #2  
Old June 9th, 2009, 12:21 AM posted to microsoft.public.access
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Validation for partial addresses

You can create a lookup table and have user select with combo box.

"Gabe" wrote:

Hello,

I was wondering if anyone might know the code to use for validating partial
addresses? The addresses in my table should look like this: Salem, OR 97301.
However, some users are putting bad data in there like: sAlem or 9730. How
can I stop this from happening?

Thanks,
~Gabe

  #3  
Old June 9th, 2009, 12:39 AM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Validation for partial addresses

On Mon, 8 Jun 2009 13:45:01 -0700, Gabe
wrote:

Hello,

I was wondering if anyone might know the code to use for validating partial
addresses? The addresses in my table should look like this: Salem, OR 97301.
However, some users are putting bad data in there like: sAlem or 9730. How
can I stop this from happening?

Thanks,
~Gabe


You're trying to store three pieces of information (city, state,zip) in one
field. That's a violation of the very basic principle that fields should be
atomic. Consider instead having three fields, one for each distinct value.

Assuming that your scope is just the US and Canada, you can use a table of
Postcodes (6 character Text to accommodate US Zip codes and Canadian
postcodes); a table of states and provinces with a two-letter text primary key
and a text field for the state/province name; and a table of cities. The user
could then *SELECT* a properly spelled and capitalized value from each table
using a combo box. With a bit of code you can even have (say) the zip code
combo automatically fill in the state, and limit the city combo to the cities
(usually but not always just one) in that zipcode.
--

John W. Vinson [MVP]
  #4  
Old June 9th, 2009, 12:47 AM posted to microsoft.public.access
John Spencer
external usenet poster
 
Posts: 2,364
Default Validation for partial addresses

It kind of depends on how you define validate and where you intend to
use this.

IF Not (Address Like "?*, ?? #####") Then
'Address does not contain at least one character
'followed by a comma, a space, two characters, a space
'and five number characters.

ElseIf strComp(Left(Address,Instr(1,Address,",")), _
StrConv(Left(Address,Instr(1,Address,",")),3),0) 0 Then
'Address City Name may be incorrectly capitalized



'================================================= ===
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'================================================= ===


Gabe wrote:
Hello,

I was wondering if anyone might know the code to use for validating partial
addresses? The addresses in my table should look like this: Salem, OR 97301.
However, some users are putting bad data in there like: sAlem or 9730. How
can I stop this from happening?

Thanks,
~Gabe

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.