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
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
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.
Check the number of characters that the user types in.Code:Private Sub Text21_Exit(Cancel As Integer) If Len(Text21) > 8 Then MsgBox "> 8" Cancel = True End If End Sub
a default is a default (single) value, not a default range, for which you would use a validation rule
>=0 and <=99999999
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?
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.
Use a Form. Do you always want 8 digits, or a maximum of 8 digits? Or is any number from 0 to 99999999 allowable?In table, Data Type (Number) how can i input 8-digit?
if the field is defined in the table as a number, the user will not be able to put other than a number there.How can i allow user just to key in just number instead of alphabet?
Last edited by davegri; 03-13-2017 at 09:56 PM. Reason: clarity
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.
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
Hi Davegri,
Noted with thanks. I will try this code when i back to work.