Behavior Entering a Field

G

Guest

Is there a way to change the default of the curser behavior as it enters the
field? Can two fields on the same form have different behaviors? Can one
field enter at the beginning of the field and another field enter at the end
of the field? If so do you have any examples?
 
A

Allen Browne

The setting under:
Tools | Options | Keyboard | Behavior Entering Field
affects all controls on all forms. Use it to set the default behavior you
want.

For an individual text box, use its Enter event to set SelStart. This
example places the cursor at the end of the Notes field:

Private Sub Notes_Enter()
With Me.Notes
.SelStart = Nz(Len(.Value), 1)
End With
End Sub
 
J

John Vinson

Is there a way to change the default of the curser behavior as it enters the
field? Can two fields on the same form have different behaviors? Can one
field enter at the beginning of the field and another field enter at the end
of the field? If so do you have any examples?

You can use the SelStart and SelLength properties of a control to
select where the cursor appears - see the VBA online help for some
examples.

John W. Vinson[MVP]
 
G

Guest

Thanks Allen!

How do I use this with a Zoom Box. I guess what I'm asking is how do I
identify a Zoom Box on a control?
 
A

Allen Browne

Replace the zoom box with your own unbound form, so you can control the
behavior. The form will need one large text box with Ok and Cancel buttons.

Use an AutoKeys macro to reassign Shift+F2 to a function in a standard
module.

Examine Screen.ActiveControl (with error handling in case no form is
active.)

Assign this control to a public variable of type TextBox (or perhaps
Control.)

Open your form in dialog mode, and assign the large text box the Value of
the public variable, and then set SelStart the way you want.

In the Ok button's Click event, assign the control the value of the large
text box, and then set your public control to Nothing and close the form.

In the Cancel button, just close the dialog.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top