• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 594
  • Last Modified:

limit field size of a memo field

Is there a way to limit the amount of characters in a memo field to 2000?

Thanks,
Jenn~
0
Jennerator
Asked:
Jennerator
  • 4
  • 3
  • 2
  • +1
1 Solution
 
Rey Obrero (Capricorn1)Commented:
you can set the validation in the design view of the table

validation rule  len([MemoFieldName])<=2000

or you can check the length of the text in the forms control events
0
 
peter57rCommented:
2000 characters is a lot of data to be entering.
How are you entering it?
0
 
TextReportCommented:
You can use the BeforeUpdate event of the control.
Cheers, Andrew
Private Sub Text2_AfterUpdate()
    If Len(Nz(Me.Text2,"")) > 2000 Then
       Me.Text2 = Left(Text2, 2000)
    End If
End Sub

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JenneratorAuthor Commented:
Peter58r, It is a memo field that will be imported in to another database that has a limit of 2000 and we didn't want any data to be cut off in the second db so we thought if we could limit what they can type in, it will prevent a problem on the other db. I think it is just a notes field. I am not sure as I was just asked to ask the question.

Thanks capricorn1, we will try your suggestion
0
 
JenneratorAuthor Commented:
Hello, These both worked, but not until the user moves the next field. At that point they don't know how far over they went and would not want to start over. Is there anyway to have them know that they have hit the 2000 while they are typing?
0
 
Rey Obrero (Capricorn1)Commented:
yes, you can do that in the forms module using the KeyPress or Keydown event

0
 
JenneratorAuthor Commented:
Cool, I never noticed those before. It always makes me wonder on how much I am overlooking in Access. I tried the code above in both the KeyPress and KeyDown events but it is ignoring it. What am I doing wrong? Is that not what you meant?
0
 
Rey Obrero (Capricorn1)Commented:
try the change event, my last post
0
 
TextReportCommented:
You can use the On Change event but you will also need to use the Text property in the code. I would also suggest that you put a MsgBox in it to advise the user.

Cheers, Andrew

Private Sub Text0_Change()
    If Len(Nz(Me.Text0.Text, "")) > 2000 Then
       Me.Text0.Text = Left(Me.Text0.Text, 2000)
    End If
End Sub

Open in new window

0
 
Rey Obrero (Capricorn1)Commented:
my post was lost?????

private sub text1_change()
dim str as string
str=str & me.text1.text

if len(str)=2000 then
  msgbox "Limit is reached"
  ' other codes here
end if

end sub
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now