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 » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Validation rule for 1 capital letter?



 
 
Thread Tools Display Modes
  #1  
Old August 18th, 2005, 03:55 PM
BBoller
external usenet poster
 
Posts: n/a
Default Validation rule for 1 capital letter?

Hi all - apologies if this is a stupid question! I have a colleague who is
attempting to set up a Validation Rule so that the first letter in the field
must be a capital letter. He wants to use that rather than an input mask so
that an error message is received if the capital letter is not entered. I
have looked around for something similar and being (admittedly) new to the
idea of Validation rules, I'm stuck. Can anyone offer any suggestions?

Thank you!
  #2  
Old August 18th, 2005, 04:00 PM
Rick B
external usenet poster
 
Posts: n/a
Default

I think you'd use something like...

Left([somecontrol],1) = UCase(Left([Somecontrol],1))



I have not tested that though.

--
Rick B



"BBoller" wrote in message
...
Hi all - apologies if this is a stupid question! I have a colleague who is
attempting to set up a Validation Rule so that the first letter in the

field
must be a capital letter. He wants to use that rather than an input mask

so
that an error message is received if the capital letter is not entered. I
have looked around for something similar and being (admittedly) new to the
idea of Validation rules, I'm stuck. Can anyone offer any suggestions?

Thank you!



  #3  
Old August 18th, 2005, 04:32 PM
external usenet poster
 
Posts: n/a
Default


BBoller wrote:
I have a colleague who is
attempting to set up a Validation Rule so that the first letter in the field
must be a capital letter.


I don't think you'll have any luck because the check is case
insensitive

  #4  
Old August 18th, 2005, 05:18 PM
Ken Snell [MVP]
external usenet poster
 
Posts: n/a
Default

Rick's suggestion will work in EXCEL VBA, which is case-sensitive when
comparing a value in a cell, but not in ACCESS VBA, which is not
case-sensitive when comparing a value in a control.

Use StrComp function, or do an Asc() comparison.

This:
If StrComp(Left([somecontrol],1), UCase(Left([Somecontrol],1)), _
vbBinaryCompare) 0 Then
' they don't match
Else
' they do match
End If


or this:
If Asc(Left([somecontrol],1)) Asc(UCase(Left([somecontrol],1))) Then
' they don't match
Else
' they do match
End If

--

Ken Snell
MS ACCESS MVP





"Rick B" Anonymous wrote in message
...
I think you'd use something like...

Left([somecontrol],1) = UCase(Left([Somecontrol],1))



I have not tested that though.

--
Rick B



"BBoller" wrote in message
...
Hi all - apologies if this is a stupid question! I have a colleague who
is
attempting to set up a Validation Rule so that the first letter in the

field
must be a capital letter. He wants to use that rather than an input mask

so
that an error message is received if the capital letter is not entered. I
have looked around for something similar and being (admittedly) new to
the
idea of Validation rules, I'm stuck. Can anyone offer any suggestions?

Thank you!





  #5  
Old August 18th, 2005, 10:58 PM
Jeff Boyce
external usenet poster
 
Posts: n/a
Default

Why? If the only purpose of the validation check is to tell the user s/he
didn't capitalize the first character, why not just capitalize the first
character for him/her, no matter what?

Regards

Jeff Boyce
Access MVP

"BBoller" wrote in message
...
Hi all - apologies if this is a stupid question! I have a colleague who is
attempting to set up a Validation Rule so that the first letter in the
field
must be a capital letter. He wants to use that rather than an input mask
so
that an error message is received if the capital letter is not entered. I
have looked around for something similar and being (admittedly) new to the
idea of Validation rules, I'm stuck. Can anyone offer any suggestions?

Thank you!



  #6  
Old August 19th, 2005, 08:21 AM
external usenet poster
 
Posts: n/a
Default


Jeff Boyce wrote:
Why? If the only purpose of the validation check is to tell the user s/he
didn't capitalize the first character,


Good point. The answer is, there is a difference between validation in
the front end application, which is this case is Access, and a
constraint in the database i.e. a CHECK constraint a.k.a. Validation
Rule. After Access, Excel the next most popular application used to
access data in a Jet database. Putting validation in an Access form
will not prevent the same user with the same permissions putting bad
data into the same Jet database while connected via Excel. Because the
CHECK is applied at the data engine level, it applies equally to *all*
front end/middle tier applications, so data integrity is ensured.

why not just capitalize the first
character for him/her, no matter what?


Another good point. Best to fix the leak as well as mopping the floor:

http://www.dbazine.com/ofinterest/oi-articles/celko25

  #7  
Old August 19th, 2005, 08:22 AM
external usenet poster
 
Posts: n/a
Default


Ken Snell [MVP] wrote:
Rick's suggestion will work in EXCEL VBA, which is case-sensitive when
comparing a value in a cell, but not in ACCESS VBA, which is not
case-sensitive when comparing a value in a control.


Another thought: the OP could test the ascii value of the first
character e.g.

CREATE TABLE Test (
last_name VARCHAR(35) NOT NULL,
CHECK(ASC(LEFT$(last_name, 1)) BETWEEN 65 AND 90)
);

  #8  
Old August 19th, 2005, 09:19 AM
BBoller
external usenet poster
 
Posts: n/a
Default

Thank you all for your help! I had the same question, but he is teaching and
wanted to do it this particular way. I'll pass everything along that was
suggested. I appreciate it!

" wrote:


Jeff Boyce wrote:
Why? If the only purpose of the validation check is to tell the user s/he
didn't capitalize the first character,


Good point. The answer is, there is a difference between validation in
the front end application, which is this case is Access, and a
constraint in the database i.e. a CHECK constraint a.k.a. Validation
Rule. After Access, Excel the next most popular application used to
access data in a Jet database. Putting validation in an Access form
will not prevent the same user with the same permissions putting bad
data into the same Jet database while connected via Excel. Because the
CHECK is applied at the data engine level, it applies equally to *all*
front end/middle tier applications, so data integrity is ensured.

why not just capitalize the first
character for him/her, no matter what?


Another good point. Best to fix the leak as well as mopping the floor:

http://www.dbazine.com/ofinterest/oi-articles/celko25


  #9  
Old August 19th, 2005, 02:05 PM
Ken Snell [MVP]
external usenet poster
 
Posts: n/a
Default

Yep, that would work... I just can never remember the exact ascii number for
those letters, and always have to go look them up or run a test in the
Immediate Window... laziness sometimes interferes!

--

Ken Snell
MS ACCESS MVP

wrote in message
ups.com...

Ken Snell [MVP] wrote:
Rick's suggestion will work in EXCEL VBA, which is case-sensitive when
comparing a value in a cell, but not in ACCESS VBA, which is not
case-sensitive when comparing a value in a control.


Another thought: the OP could test the ascii value of the first
character e.g.

CREATE TABLE Test (
last_name VARCHAR(35) NOT NULL,
CHECK(ASC(LEFT$(last_name, 1)) BETWEEN 65 AND 90)
);



  #10  
Old August 19th, 2005, 02:40 PM
external usenet poster
 
Posts: n/a
Default


Ken Snell [MVP] wrote:
I just can never remember the exact ascii number for
those letters, and always have to go look them up or run a test in the
Immediate Window... laziness sometimes interferes!


OK this then, which does actually read better:

CHECK(ASC(LEFT$(last_name, 1)) BETWEEN ASC('A') AND ASC('Z'))



 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation rule hughess7 General Discussion 3 August 4th, 2005 07:28 PM
Convert to Symbols Omar Menjivar General Discussion 7 June 27th, 2005 07:32 PM
Validation Rule - must have at least 1 number and 1 letter kishan Database Design 3 April 25th, 2005 02:18 PM
Fw: Validation rule problem Geo Using Forms 0 September 14th, 2004 08:38 AM
Validation Rule question Lori Using Forms 1 July 20th, 2004 06:32 PM


All times are GMT +1. The time now is 07:33 AM.


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