How to auto TAB when control has 6 chars entered

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can't figure out how to automatically tab to next control when a control has
say 6 digits entered.
 
ThomasAJ said:
Can't figure out how to automatically tab to next control when a
control has say 6 digits entered.

If you give your control an input mask (so that Access knows how many
digits it should allow), you can get this behavior by setting the
control's Auto Tab property to Yes. The Input Mask property is on the
Data tab of the control's property sheet, and the Aut Tab property is on
the Other tab of the property sheet.
 
Hi, ThomasAJ.

Use the control's On Got Focus event to set the focus to the next control.
Use a boolean expression to determine whether the control has six characters
entered, or is greater or equal to 100000, or some other custom function.

' Criteria is a string at least 6 characters long
If len(Me![YourControl]) >=6 Then...

' Criteria is a number greater or equal to 100000
If Me![YourControl] >= 1000000 Then

' If you need some custom function (Named DataIsValid in this example) to
determine the criteria
If DataIsValid([MyControl]) Then

In all cases, if the expression evaluates to True, set the focus to your
next control:

Me![MyNextControl].SetFocus

replacing "MyNextControl" with the name of the control to which you'd like
to set the focus.

Sprinks
 
Thanks Dirk that's great.

Can I change the default error message that Accees issues.
It is very user unfriendly. "The value you entered....mask '0000'...etc".
 
ThomasAJ said:
Thanks Dirk that's great.

Can I change the default error message that Accees issues.
It is very user unfriendly. "The value you entered....mask
'0000'...etc".
Thanks Dirk that's great.

Can I change the default error message that Accees issues.
It is very user unfriendly. "The value you entered....mask
'0000'...etc".


Unfortunately, you can't control that at the level of the control
itself. If you use an input mask, the only way I know of to override
the error message is to catch it in the form's Error event, using an
event procedure similar to this:

'----- start of code -----
Private Sub Form_Error(DataErr As Integer, Response As Integer)

If DataErr = 2279 Then

MsgBox _
"Please enter 6 digits.", _
vbExclamation, _
"Invalid Entry"

Response = acDataErrContinue

End If

End Sub
'----- end of code -----

You might need to modify the above code to check the form's
ActiveControl property to see which specific control raised the error
and display an appropriate error message accordingly.
 
Back
Top