Re: Best Logic to solve this
where do you get the validation value?
Re: Best Logic to solve this
I would suggest useing the Lost_Focus() Event of each TextBox to validate the data. IE. Initiating as a result of pressing a CommandButton.
If the Text1_LostFocus() event validates the data, then disable, and enable TextBox2 etc....
And.... use a Control Array of TextBox's too :)
Re: Best Logic to solve this
Re: Best Logic to solve this
Seems like you are correctly disabling the textboxes but you are not removing its contents, so each time you disable a textbox empty its .Text property: text2.text = VbNullString
Re: Best Logic to solve this
Eg:
VB Code:
Option Explicit
Private Sub Text1_LostFocus(Index As Integer)
If IsNumeric(Text1(Index).Text) Then
'Do something
Text1(Index).Enabled = False
If Index < Text1.Count - 1 Then Text1(Index + 1).Enabled = True
Else
'Data entry error
Text1(Index).SetFocus
MsgBox "Please enter xxxxxx.", vbOKOnly + vbInformation, "Data Entry Error!"
End If
End Sub
Re: Best Logic to solve this
Quote:
Originally Posted by jcis
Seems like you are correctly disabling the textboxes but you are not removing its contents, so each time you disable a textbox empty its .Text property: text2.text = VbNullString
I take care of that in my example above, by re focusing until the data is correct.
Re: Best Logic to solve this
VB Code:
Option Explicit
Dim intTBCount As Integer
Private Sub Form_Load()
Dim intIdx As Integer
intTBCount = Text1.Count - 1
For intIdx = 1 To intTBCount 'Skip the first TextBox
Text1(intIdx).Enabled = False
Next
End Sub
Private Sub Text1_LostFocus(Index As Integer)
If IsNumeric(Text1(Index).Text) Then
'Do something
Text1(Index).Enabled = False
If Index < intTBCount Then Text1(Index + 1).Enabled = True
Else
'Data entry error
Text1(Index).SetFocus
Text1(Index).SelStart = 0
Text1(Index).SelLength = Len(Text1(Index).Text)
MsgBox "Please enter xxxxxx.", vbOKOnly + vbInformation, "Data Entry Error!"
End If
End Sub
Or alternatly, using the Validate Event:
VB Code:
Option Explicit
Dim intTBCount As Integer
Private Sub Form_Load()
Dim intIdx As Integer
intTBCount = Text1.Count - 1
For intIdx = 1 To intTBCount 'Skip the first TextBox
Text1(intIdx).Enabled = False
Next
End Sub
Private Sub Text1_Validate(Index As Integer, Cancel As Boolean)
If IsNumeric(Text1(Index).Text) Then
'Do something
Text1(Index).Enabled = False
If Index < intTBCount Then Text1(Index + 1).Enabled = True
Else
'Data entry error
Cancel = True
MsgBox "Please enter xxxxxx.", vbOKOnly + vbInformation, "Data Entry Error!"
End If
End Sub
Re: Best Logic to solve this
is there any generic solution other than using array textbox when another control frame of combobox?
Re: Best Logic to solve this
Quote:
Originally Posted by barianto
is there any generic solution other than using array textbox when another control frame of combobox?
And how does that relate to your subject post??????
Re: Best Logic to solve this
sorry,
I just found out that i need using frame
Re: Best Logic to solve this
And ComboBoxs or TextBox's......???? :)
Also, for what it's worth, I added similar code (above) to validate using the TextBox Validate() Event - setting Cancel = True.