1

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 Answers2

1

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.

June7
  • 19,874
  • 8
  • 24
  • 34
0

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]))
Gustav
  • 53,498
  • 7
  • 29
  • 55