text field formatting

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

i m using access 2003 and designing one forms which has
two text field..one for name and another for address..
in address field, i have multiple line enabled and i want
to resrict to maximum number of lines only to 3.
in the name field, i want to change string to proper once
focus is lost..i.e.
mr. abc xyz-------->Mr. Abc Xyz
MR. ABC XYZ-------->Mr. Abc Xyz
and address text field can have maximum 3 lines..user
should not be able to enter 4th line..

any help would be appreciated..

thnx in advance
dave
 
You can put the following code in the before update event


If IsNull(Me.Address) = False Then

If UBound(Split(Me.Address, vbCrLf), 1) > 2 Then
Cancel = True
MsgBox "You are only allowed 3 lines max", vbExclamation
End If
End If


The split command produces a zero based array...so, "2" means 3 lines....
 
Back
Top