1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Form question in access

Discussion in 'Business Applications' started by clmowers, Jun 4, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. clmowers

    clmowers Thread Starter

    Joined:
    Jun 20, 2005
    Messages:
    303
    I have a form in a database and i need to make sure that there are 24 letters in the textbox before they update. I tried a few things, but it was basiclly limiting the number to 24 instead of how many there are. How do i do this
     
  2. Ziggy1

    Ziggy1

    Joined:
    Jun 17, 2002
    Messages:
    2,551
    did you try an input mask? you can do this in the text box or the table's field property, just fill it up with 24 capitol L's
     
  3. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Do you mean that you want a Minimum of 25 characters in the field, but there could be more than 24?
     
  4. Ziggy1

    Ziggy1

    Joined:
    Jun 17, 2002
    Messages:
    2,551
    Here is one way, I'm sure OBP has some tricks up his sleeve. don't use the input mask but if the field must contain 24 char then set the size to 24 in the table.

    Set the form property for Data entry to YES, remove the record selectors and add your own. Place this code under each, but change this part depending on which choice it is...

    DoCmd.GoToRecord , , acNewRec


    change the acNewRec part to acNext, acPrevious etc





    Code:
    Private Sub Command74_Click()
    
    On Error GoTo Err_Command74_Click
    
    
    ' checks the Length and for text
    If Len(Me.EnteredBy) = 24 And Me.EnteredBy Like "*[a-z]*" Then
       DoCmd.GoToRecord , , acNewRec
       
       'changes backcolor to white after record is added
       Me.EnteredBy.BackColor = RGB(255, 255, 255)
         Exit Sub
       End If
    
    Exit_Command74_Click:
    
    MsgBox "Field must be 24 charaxcters long and only contain letters"
    
    'sets focus to control to fix and changes to yellow
    Me.EnteredBy.SetFocus
    Me.EnteredBy.BackColor = RGB(255, 255, 0)
    
        Exit Sub
    
    Err_Command74_Click:
        MsgBox Err.Description
        Resume Exit_Command74_Click
    
    
    End Sub
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/718414

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice