free text boxes and scroll option

L

Lauren B.

I have two general questions...

1. I created a free text "notes" box on a form for users to enter misc.
information. When typing inside the box, if you hit "enter" the user is
moved out of the box. How can enable a user to use the "enter" key in the
free text box?

2. Is there a way to disable movement between records in a form through the
use of the scroll wheel on the mouse. The form I am speaking of is lenghtly
enough to have a scroll bar. When users attempt to scroll down to the lower
portion of the form, they are automatically taken to a blank record.

Any suggestions are appreciated. Thank you in advance for your help.
 
D

Douglas J. Steele

1) Text box controls have a property named EnterKeyBehaviour. If you look at
that property through the GUI, you can set it to "New Line In Field". (If
you're trying to set the property in VBA code, you set it to True)

2) Check out what Stephen Lebans has at
http://www.lebans.com/mousewheelonoff.htm
 
D

DebbieG

The following works to disable the MouseWheel in single form, not in
continuous forms.

Hope that helps,
Debbie

On your form, place an unbound TextBox with the following properties:

Name = UnboundTextBox
Default Value = " "
Validation Rule = WheelSpin() = False
Visible = Yes
Enabled = Yes
Locked = No
Tab Stop = No
Back Style = Transparent
Back Color = -2147483633 ' or whatever the color of the form is
Fore Color = -2147483633
Special Effect = Flat
Border Style = Transparent

On your Form Properties set:
On Mouse Wheel = [Event Procedure]
On Error = [Event Procedure]

Put the following code behind your form:

Private mWheel As Boolean
Private validationTrigger As wsTrigger

' This Enum is for clarifying the code below
Private Enum wsTrigger
MyWheel = 1
NotTheWheel = 2
End Enum

Private Function WheelSpin() As Integer
WheelSpin = mWheel
Select Case validationTrigger
Case NotTheWheel
mWheel = False
End Select
End Function
_______________________________________________________________

Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
On Error GoTo GotError
' allow MouseWheel if not editing or new record
If Me.Dirty Or Me.NewRecord Then - COMMENT THIS OUT IF WANTING TO
TOTALLY DISABLE
mWheel = True
validationTrigger = MyWheel
Me.UnboundTextBox.SetFocus
Me.UnboundTextBox.Text = " "
End If - COMMENT THIS
OUT IF WANTING TO TOTALLY DISABLE

ExitSub:
validationTrigger = NotTheWheel
Exit Sub

GotError:
' Value you entered doesn't meet the validation rule
If Err.Number = 2107 Then
Msgbox "You need to complete this record first." - COMMENT THIS
OUT IF WANTING TO TOTALLY DISABLE
Resume ExitSub
End If
' if any other error show error number, error description, and where the
error occurred
MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf &
"Form_MouseWheel"
Resume ExitSub
End Sub
_______________________________________________________________

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If Screen.ActiveControl.Name = "UnboundTextBox" Then
Response = acDataErrContinue
End If
End Sub


|I have two general questions...
|
| 1. I created a free text "notes" box on a form for users to enter misc.
| information. When typing inside the box, if you hit "enter" the user is
| moved out of the box. How can enable a user to use the "enter" key in the
| free text box?
|
| 2. Is there a way to disable movement between records in a form through
the
| use of the scroll wheel on the mouse. The form I am speaking of is
lenghtly
| enough to have a scroll bar. When users attempt to scroll down to the
lower
| portion of the form, they are automatically taken to a blank record.
|
| Any suggestions are appreciated. Thank you in advance for your help.
|
|
 
Top