Results 1 to 5 of 5
  1. #1
    G.King is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jun 2011
    Location
    Essex, England
    Posts
    7

    Memo type limit


    I have a field set as a memo data type as I need to capture a reasonable sized comment; however, memo allows entire essays to be entered. Any ideas as to how I can limit the quantity of text entered to say 750 characters?

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    In the KeyPress event of the text box used to enter to that field you can use code like this:

    Code:
    If Len(Me.YourControlName.Text) = 750 Then
       KeyAscii = 0
       Msgbox "You have reached the limit of characters you can type here.", vbInformation, "Limit Reached"
    End If

  3. #3
    G.King is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jun 2011
    Location
    Essex, England
    Posts
    7

    Didn't quite work

    Really appreciate the suggestion but can't get it to work. When I enter the code into the expression builder I get a message saying, 'The expression you entered contains Invalid syntax'. I don't really do much coding but get the logic of the code. I assume I'm substituting the control name incorrectly. The textbox on the form is named Statement.

    I've entered,

    If Len(Me.statement.Text) = 750 Then
    KeyAscii = 0
    Msgbox "You have reached the limit of characters you can type here.", vbInformation, "Limit Reached"
    End If

    I've also tried,

    If Len(Me.[statement].Text) = 750 Then
    KeyAscii = 0
    Msgbox "You have reached the limit of characters you can type here.", vbInformation, "Limit Reached"
    End If

    Same error message both times. Any suggestions?

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    First off, are you typing this in the actual VBA window? It doesn't seem like you are. When you click in the KEYDOWN event property of the text box named "statement" are you selecting [Event Procedure] from the drop down and then clicking the Ellipsis (...) to open the VBA window?

  5. #5
    G.King is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jun 2011
    Location
    Essex, England
    Posts
    7

    Sorted

    Was pressing the 3 elipses but then expression builder rather than code builder [told you I don't do coding]. Tried through the code builder and it now works perfectly.

    Brilliant! You are a top man Bob. Thanks!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Limit to Arguments?
    By ducecoop in forum Access
    Replies: 4
    Last Post: 11-01-2010, 01:52 PM
  2. Partial Limit
    By bglaugh in forum Programming
    Replies: 1
    Last Post: 09-15-2010, 06:49 AM
  3. Limit Records
    By EHittner in forum Forms
    Replies: 1
    Last Post: 05-03-2010, 10:37 AM
  4. Replies: 2
    Last Post: 03-18-2010, 08:24 PM
  5. mdb file size limit
    By dr_ping in forum Access
    Replies: 1
    Last Post: 01-19-2009, 09:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums