Stop auto-highlighting on text box Zoom (1 Viewer)

Greyowlsl

Mlak Mlak
Local time
Today, 22:15
Joined
Oct 4, 2006
Messages
206
Hi,

I have a text box with a memo control source, when you click the text box an acCmdZoomBox is run. However when the Zoom box opens it highlights all of the data, which is causing issues with people accidentally deleting all the information. I have seen something about a selstart, sellength command, but i don't know how to refer that to a zoom box.
Also is it possible to carriage return on a Zoom Box memo, or even text box?

Thanks.
 

missinglinq

AWF VIP
Local time
Today, 08:15
Joined
Jun 20, 2003
Messages
6,420
Is this the same behavior exhibited when entering all Controls on the Form? The only way I could reproduce your problem is if the 'Behavior on Entering Field,' in Options, is set to 'Select Entire Field.' This is a machine specific setting, i.e. how it is set is dependent on the particular copy of Access that is being used. Fixing it on your machine doesn't mean it will be fixed on other machines running your app.

You can override this option, in a normal Control, using

Me.YourTextBoxName.SelStart = 0

in the GotFocus and OnClick event of a Control.

But I know of no way to set this for a Zoombox. My guess would be that you're going to have to 'roll your own,' in order to be able to control this behavior.

Here's a hack I wrote years ago for doing just that:

This only works in or Single View Forms!

A fairly simple way to roll your own Zoombox is to place a large Textbox (call it MyZoomBox) on your Form. Format it as you like, position as you like and assign it the same Control Source as the Field you want to expand. Yes, a Form can have two Textboxes with the same Control Source!

Substitute the actual name of your Control to be expanded for YourTextBox.

Code:
Private Sub Form_Load()
     'Make the Zoombox invisible on loading the form    
      MyZoomBox.Visible = False
End Sub

Private Sub YourTextBox_DblClick(Cancel As Integer)
    'When you double click the field, make the MyZoomBox
        'visible and move the cursor to the beginning to
        'deselect the text  
        MyZoomBox.Visible = True
        MyZoomBox.SetFocus    
        MyZoomBox.SelStart = 0
End Sub

Private Sub MyZoomBox_DblClick(Cancel As Integer)
        'Double click the MyZoomBox to close it and
        'return to your original field
    Me.YourTextBox.SetFocus
    MyZoomBox.Visible = False
End Sub
Now make the Zoombox visible by double-clicking the Control you want expanded. Do whatever you want to the data, then double-click the Zoombox to close it.

Now you can use SelStart, as outlined above, to control the behavior when the 'MyZoomBox' Textbox pops up.

Linq ;0)>
 

Greyowlsl

Mlak Mlak
Local time
Today, 22:15
Joined
Oct 4, 2006
Messages
206
Thanks missinglinq,

The option thing works fine for the moment, but i may need to use your code later if people start complaining that the other text boxes are no longer auto-highlighting... maybe they wont notice, haha.
 

missinglinq

AWF VIP
Local time
Today, 08:15
Joined
Jun 20, 2003
Messages
6,420
I advise all users to never set the 'Behavior on Entering Field' Option to 'Select Entire Field' for the very reason you cite, the increased chance of accidentally deleting vital information! And sadly, the average user isn't aware that pressing the <Esc> Key, immediately, will undo the Deletion!

Linq ;0)>
 

Users who are viewing this thread

Top Bottom