Results 1 to 9 of 9
  1. #1
    Jeremy Sng is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Aug 2016
    Posts
    43

    How to set maximum 8 digit number in default?

    Hi Everyone,

    How can i set maximum 8 digit value in default value?

    Currently i put "00000000" but i able to key "000000001"



    Thanks

    Regards
    Jeremy Sng

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    if 8 is the max, then set the field string length to 8
    if the string can be more, then you cant really set a default since the user can type anything.

  3. #3
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Code:
    Private Sub Text21_Exit(Cancel As Integer)
        If Len(Text21) > 8 Then
            MsgBox "> 8"
            Cancel = True
        End If
    End Sub
    Check the number of characters that the user types in.

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    a default is a default (single) value, not a default range, for which you would use a validation rule

    >=0 and <=99999999

  5. #5
    Jeremy Sng is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Aug 2016
    Posts
    43
    How can i allow user just to key in just number instead of alphabet?

    In table, Data Type (Number) how can i input 8-digit?

  6. #6
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    We aren't making progress here because we don't know exactly what you want. Please explain clearly how you input the data and what you expect the user to see if there is an error.
    In table, Data Type (Number) how can i input 8-digit?
    Use a Form. Do you always want 8 digits, or a maximum of 8 digits? Or is any number from 0 to 99999999 allowable?
    How can i allow user just to key in just number instead of alphabet?
    if the field is defined in the table as a number, the user will not be able to put other than a number there.
    Last edited by davegri; 03-13-2017 at 09:56 PM. Reason: clarity

  7. #7
    Jeremy Sng is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Aug 2016
    Posts
    43
    Hi Davegri,

    Sorry, can Ignore the first question.

    Yes, i want the user key in 8 digits of number. Eg. (12345678)

    Currently i face is user can insert alphabet in the box.

  8. #8
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    I think this will do the job. The textbox is named txtMy8Digit.

    Code:
    Private Sub txtMy8Digit_Exit(Cancel As Integer)
        Dim nLen As Integer
        nLen = Len(txtMy8Digit.Text)
        If nLen < 8 Or nLen > 8 Then
            Cancel = True
            txtMy8Digit.SelStart = nLen + 1
        End If
    End Sub
    
    
    Private Sub txtMy8Digit_Keyup(KeyCode As Integer, Shift As Integer)
        Dim sLimit As Long
        sLimit = Nz(Len(txtMy8Digit.Text))
        'Debug.Print txtMy8Digit.Text & " " & sLimit
        If sLimit > 8 Then
            txtMy8Digit.Text = Left(txtMy8Digit.Text, 8)
        End If
    End Sub

  9. #9
    Jeremy Sng is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Aug 2016
    Posts
    43
    Hi Davegri,

    Noted with thanks. I will try this code when i back to work.

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

Similar Threads

  1. Need Help Setting a Maximum Number
    By kreelix in forum Access
    Replies: 3
    Last Post: 10-13-2015, 05:26 PM
  2. auto generate a 5 digit number?
    By Andre73 in forum Access
    Replies: 2
    Last Post: 02-18-2015, 07:45 AM
  3. Minimum and Maximum Number
    By mohanmoni in forum Queries
    Replies: 3
    Last Post: 02-04-2015, 01:55 PM
  4. Replies: 1
    Last Post: 01-11-2012, 03:07 PM
  5. Access 2007: Can't Display 17 Digit Number
    By HedgeHog in forum Access
    Replies: 9
    Last Post: 08-14-2011, 01:46 PM

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