Accept one number

C

Chris Wagner

I have 5 fields that are numeric. They can accept the numbers from 1 to
5. (<6) 0 decimal place. What I am trying to do is have the field
only accept one number which is less than 6 and then move to the next
field without having to press enter or tab. Any suggestions

Thanks
Chris
 
T

Tom Collins

Try these events for each of these fields:

Private Sub Field1_BeforeUpdate(Cancel As Integer)
If Field1.Value > 5 Then
Cancel = True
End If
End Sub

Private Sub Field1_Change()
On Error GoTo Err_Field1
Field2.SetFocus
Exit_Field1:
Exit Sub
Err_Field1:
Field1.SelStart = 0
Field1.SelLength = 1
Resume Exit_Field1
End Sub


Tom Collins

| I have 5 fields that are numeric. They can accept the numbers from
1 to
| 5. (<6) 0 decimal place. What I am trying to do is have the field
| only accept one number which is less than 6 and then move to the
next
| field without having to press enter or tab. Any suggestions
|
| Thanks
| Chris
|
 
C

Chris Wagner

Thanks for the help Tom.

As coming from dBase programming and not fully understanding where to
place the below code..... I was able to find another solution

in the property box for each field....

set the Input Mask to 9
set the Auto Tab to Yes

I think i need some schooling in Access to understand fully how to put in
these types of events that you sent.

Thanks again

Chris Wagner
 
T

Tom Collins

It sounds like you found a much better solution.

What I sent was VBA code. You can get to it a variety of ways. The
Events tab in the Properties window is one way.

I'm glad you found the solution yourself. It's always more rewarding
that way. Good luck in the future.

Tom Collins


| Thanks for the help Tom.
|
| As coming from dBase programming and not fully understanding where
to
| place the below code..... I was able to find another solution
|
| in the property box for each field....
|
| set the Input Mask to 9
| set the Auto Tab to Yes
|
| I think i need some schooling in Access to understand fully how to
put in
| these types of events that you sent.
|
| Thanks again
|
| Chris Wagner
|
| Tom Collins wrote:
|
| > Try these events for each of these fields:
| >
| > Private Sub Field1_BeforeUpdate(Cancel As Integer)
| > If Field1.Value > 5 Then
| > Cancel = True
| > End If
| > End Sub
| >
| > Private Sub Field1_Change()
| > On Error GoTo Err_Field1
| > Field2.SetFocus
| > Exit_Field1:
| > Exit Sub
| > Err_Field1:
| > Field1.SelStart = 0
| > Field1.SelLength = 1
| > Resume Exit_Field1
| > End Sub
| >
| > Tom Collins
| >
| > | > | I have 5 fields that are numeric. They can accept the numbers
from
| > 1 to
| > | 5. (<6) 0 decimal place. What I am trying to do is have the
field
| > | only accept one number which is less than 6 and then move to the
| > next
| > | field without having to press enter or tab. Any suggestions
| > |
| > | Thanks
| > | Chris
| > |
|
 
Top