Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input Mask - text box on form....User Trouble!

Status
Not open for further replies.

Phil4tektips

Technical User
Jul 18, 2005
89
GB
Dear All,

I have a couple of text boxes on a form formatted so that a typed forename is in the format "Joe" and the surname is in the format "BLOGGS".

Most users tab across the fields which start the blinking cursor at the first character of the input mask. But some users keep using their mouse to click in the text box which starts the blinking cursor in the middle of the Input Mask. When they've finished with the form and try to close it fails because it cant write to the table which also has the input mask assigned to it.

How can I get the cursor to start at the first letter of the input mask when a user clicks in the text box with the mouse?

Thanks in advance.

~Phil4tektips~
Grant us peace in our days work!
 
Have a look at the SelStart and SelLength properties of the TextBox object you may play with in the Enter or GotFocus event procedures.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Utilize the SelStart property of the textbox
Code:
Private Sub Text0_Click()
Me.Text0.SelStart = 0
End Sub

________________________________________________________________________
Zameer Abdulla
Visit Me
A person who misses a chance and the monkey who misses its branch can't be saved.
 
PHV, I am sorry I didn't refresh the page..

________________________________________________________________________
Zameer Abdulla
Visit Me
A person who misses a chance and the monkey who misses its branch can't be saved.
 
Zameer, no need to be sorry.
You added the info about the Click event I missed.
 
That works a treat guys, thankyou very much.

Its always difficult searching for functions. You know what you want to do, look for it on help and in FAQ's but I always find it difficult to locate exactly what function it is I need.

So thanks again for your help.

~Phil4tektips~
Grant us peace in our days work!
 
In addition to above (which has solved most of these problems) I get the same problem when the user adds new details to a table.

The user on a click of a button is taking to an 'acAdd' view of the table and allowed to add a new row. On this there is no event procedure that I can put some VB code on.

Can I get round it....or shall I just make a form for them to do it in?

Thanks.

~Phil4tektips~
Grant us peace in our days work!
 
Can you please re-write it more precise?

________________________________________________________________________
Zameer Abdulla
Visit Me
A person who misses a chance and the monkey who misses its branch can't be saved.
 
Have a look at the NewRecord property and/or the BeforeInsert event procedure of the Form object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Sorry.

It is the same problem as the start of the thread. Instead of the problem being in a text box of a form (which is now solved using your suggestions) it is in a cell of a table.

So I would like the cursor to jump to the first character of an input mask in the cell of a table.

But when entering data in table there is no Event Propeties tab to put the VB code used above in.

Shall I therefore cut my losses and create a form for this data addition, then the form can use the same solution as previously used?

~Phil4tektips~
Grant us peace in our days work!
 
Why not using a continuous subform instead of a datasheet view ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You can utilize the events by setting in the form design view and viewing the form in datasheet.
you may need to add code to enter event too to stop corsor at the beginning if they use back arrow..
Code:
Private Sub Text0_Enter()
Me.Text0.SelStart = 0
End Sub
Or as PHV said use continues form


________________________________________________________________________
Zameer Abdulla
Visit Me
A person who misses a chance and the monkey who misses its branch can't be saved.
 
Thanks. I changed it to a SubForm and used the code.

Couldnt figure out the Datasheet issue....looks nicer as a subForm anyway! thanks

~Phil4tektips~
Grant us peace in our days work!
 
In fact when you switch to acFormDS (aka DataSheet) view you loose most of the form capabilities...
 

I've got a similar thing, but rahter than using masks, I run code on the AfterUpdate to apply the formating. The advatage is that it can resolve some stuff automatically (like Trim()) and return specific errors (like name too short, invalid character, etc)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top