B
Bharat Odedra
Hello
In a textbox on a form in access if an incorrect value is
entered a message appears asking for the correct value to
be entered. I would like this textbox to have focus and
all characters in this box to be Selected so that the user
has to type in a new value which will over write the
existing value.
The selection of the existing text needs to be done by a
function/sub so that it can be resued for other textboxs.
How do I declare a control variable in both the calling
sub and pass it on to the sub doing the selection. In the
example below I have used xxx and yyy for where the
variable needs to be declared.
In this example the calling sub is named after the
control. Is there another way of referring to the control
without using the whole control's name e.g. me.TotalValue
to refer to the control in the sub TotalValue_Afterupdate()
Thanks in advance for your help
Private Sub TotalValue_AfterUpdate()
Dim strvalue As Integer
strvalue = Len(CStr(Me.TotalValue))
If Me.TotalValue.Value <> Me.Text36.Value Then
MsgBox "The Total Value is NOT equal to the amount
ordered" & vbCrLf & "Plese re-enter the total value or
change value in denominations ordered."
SelectTBConts strvalue,XXX
Else
Me.Command10.Enabled = True
End If
End Sub
Public Sub SelectTBConts(SrtLen As Integer, XXX as YYY)
With Me!TotalValue
.SetFocus
.SelStart = 0
.SelLength = SrtLen
End With
End Sub
In a textbox on a form in access if an incorrect value is
entered a message appears asking for the correct value to
be entered. I would like this textbox to have focus and
all characters in this box to be Selected so that the user
has to type in a new value which will over write the
existing value.
The selection of the existing text needs to be done by a
function/sub so that it can be resued for other textboxs.
How do I declare a control variable in both the calling
sub and pass it on to the sub doing the selection. In the
example below I have used xxx and yyy for where the
variable needs to be declared.
In this example the calling sub is named after the
control. Is there another way of referring to the control
without using the whole control's name e.g. me.TotalValue
to refer to the control in the sub TotalValue_Afterupdate()
Thanks in advance for your help
Private Sub TotalValue_AfterUpdate()
Dim strvalue As Integer
strvalue = Len(CStr(Me.TotalValue))
If Me.TotalValue.Value <> Me.Text36.Value Then
MsgBox "The Total Value is NOT equal to the amount
ordered" & vbCrLf & "Plese re-enter the total value or
change value in denominations ordered."
SelectTBConts strvalue,XXX
Else
Me.Command10.Enabled = True
End If
End Sub
Public Sub SelectTBConts(SrtLen As Integer, XXX as YYY)
With Me!TotalValue
.SetFocus
.SelStart = 0
.SelLength = SrtLen
End With
End Sub