Question Text Box

qiqinuinaifen128

Registered User.
Local time
Today, 15:22
Joined
Dec 21, 2008
Messages
29
Hi,

I have a textbox and this textbox is for me to key in number and i want to limit the textbox must be in 9 digit. No less, No more. if key in less or more, i would like to prompt a message to notify. How should i write the code?

Thank in advance ^^
 
In the the OnlostFocus event of the text box put the following;

Code:
If Me.YourTxtBox.Value < 100000000 Or Me.YourTxtBox.Value > 999999999
     MsgBox "A Nine Digit Number is required by this Filed"
     Me.YourTxtBox.Setfocus
End If

This assumes your Text box is formatted to take a number and not a string,

if it is a string use

Code:
If Len([YourTxtBox]) < 9 Or Len([YourTxtBox]) > 9
     MsgBox "A Nine Character string is required by this Filed"
     Me.YourTxtBox.Setfocus
End If
 
Hi John,

I use the code below. But the compiler error

Code:
If Me.txtstudent_contact.Value < 100000000 Or Me.txtstudent_contact.Value > 999999999
     MsgBox "A Nine Digit Number is required by this Filed"
     Me.txtstudent_contact.SetFocus
End If

txtstudent_contact is my textbox name.

When i key in 7 digit in the textbox and click other textbox. There are syntax error show
 
Sorry my bad I forgot to put in the Then, try;

Code:
If Me.txtstudent_contact.Value < 100000000 Or Me.txtstudent_contact.Value > 999999999 [B][COLOR="Red"]Then[/COLOR][/B]
     MsgBox "A Nine Digit Number is required by this Filed"
     Me.txtstudent_contact.SetFocus
End If
 
Hi John,

Yes, it's work.

I want to create a two columns Combo and i have 114 selections.
Do you know what is the maximum selection for the combobox.

Because when i try to create this, it prompts me this message "subscript out of range"

Do you have any suggestion to me?

Thanks
 
Thank you for your reply.

It is abit complicated to me...hee hee
But tell you a good news. I try to create again.. It's a lot me to create a combo more than 144 selections.

Do you know how to write a code for, once i make an selection in a 2 columns combo box. Then another textbox will automatically display the the selection content (Column 2)

Thank you so much
 
Create an unbound text box on your form and put that code in the Control source of that text box.

You can use this method to populate a number of text boxes with different data related to the current selection in the combo box, so long as that data, is available in the control source of the Combo Box.

The text boxes will update any time the selection in the combo is changed.
 
Thank you John. I have almost half done my assigment.

Hope you can give me help for this part.

In my form, there are many textbox and combobox in my access form database. and all this details will key in manually and after key in all the data in to textbox and made all the selection.
There is a button for the user to click. After click this button, there is a message display in a TEXTBOX and this message is contain the info from the textboxs and the combobox.
Actually it is perferctly display all the info i need.

I found out it can be improve.
If let say after key in all the datas and create the message in the TEXTBOX, if the user found an mistake in the textbox or make wrong selection in the combobox, so the user will change the data in the textbox or combox.

The problem is, it needs the user remember to click the button again and get a updated message. If not the message is remain the same. Is there any other method to solve this problem.
I find under the property event there have a "onchange", can i use key in the command there to detect if the user make change in the combo or textbox it will automaticaly run the button.
 
click on Help, then type in Input Mask and press return
 

Users who are viewing this thread

Back
Top Bottom