I want to create a validation rule in access for a field which allows just values which start with Upper letter I've tried this code:StrComp ( UCase ( right([Nume],1)), right([Nume],1)=0 ,but it doesn't work
2 Answers
What does "doesn't work" mean - error message, wrong result, nothing happens?
If you want to test the starting letter then use Left(), not Right(). The expression is missing closing paren and also need compare method parameter:
StrComp(UCase(Left([Nume],1)), Left([Nume],1), 0) = 0
It does work in field ValidationRule property in table.
Will not prevent upper case letters in other positions. There is no intrinsic function in Access for sentence case. Consider:
Ucase(Left(mystring,1)) & LCase(Mid(mystring, 2))
There is StrConv() function. This will convert first letter of each word to upper case.
My preference would be VBA procedure to ensure user input in correct form instead of annoying user with hand slap, forcing them to re-enter input and slowing productivity. The above expression could serve that purpose.

- 19,874
- 8
- 24
- 34
-
It showed an error message but now it works properly.Thank you! – Anca Stefania Mar 23 '17 at 16:16
-
Gustav's simpler expression will provide same result (did not see before posting). See revised answer. – June7 Mar 23 '17 at 17:11
I don't think you can do this at the field level, but you can at the table level validation rule:
Asc([Nume])=Asc(UCase([Nume]))

- 53,498
- 7
- 29
- 55