Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

memo data type 3

Status
Not open for further replies.

ksimmsa

Programmer
Feb 6, 2004
22
US
I have a table that I need to store large free form comments. I have it set to memo, but is it possible to limit the amount of characters from 64,000.


thanks in advance for your help
 
but is it possible to limit the amount of characters from 64,000

Do you mean exceed the limit of 64k. No.

A good work-around is to use hyperlink, and link to the external document.
 
No, I don't want the users to have access to the entire 64k. I want to limit them to 500 characters.
 
Hmmmm.
I would have to play around on this, but as you probably know, a text field has a limit of 255 characters. And there is an OnKey event. You could count characters, and when 250 is reached in the first text box, you make a second text visible and reset the focus to the second text box.
 
Presumably the user will be entering the data via a text box on a form somewhere.

If this is the case then you can let the text box do the work for you.

If that text box control's NAME is txtLongNote then in design view set the Validation Rule property to :-

Len([txtLongNote])<501


And set the Validation Text property to :-

You have exceeded the allowed text length in this control. Please edit you entry and waffle less.


( you might consider it appropriate to reword the Validation Text ! - but I'm sure you get the idea. )


'ope-that-'elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
If you want users to see the character count as they type, do this:

put a text box on your form (called txtCharCount)
my memo field is called "blah"
Put this code into your memo field's OnChange event. Change 'blah' to the name of your memo field:

Code:
Private Sub blah_Change()
    Me.txtCharCount = Nz(Len(Me.blah.Text))
End Sub

Since the new text box (txtCharCount) is unbound, you have to refresh it's data each time you move to a new record in the form otherwise it retains the char count of the previous record. So in the FORM's OnCurrent event, put this:

Code:
Private Sub Form_Current()
    Me.blah.SetFocus 'Set focus to memo field
    Me.txtCharCount = Nz(Len(Me.blah.Text))
End Sub

The focus has to be set to the memo field otherwise there's an error. If you then want the cursor to go back to a different field on the form, just put another setfocus line after setting txtCharCount.

That was fun :)

g

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top