|
-
Jul 31st, 2006, 11:17 PM
#1
Thread Starter
Addicted Member
Best Logic to solve this
Hi,
I have little logic problem here
It's like this.
I have 4 textbox :Text1, Text2, Text3, Text4
At start Text1 enabled is true, other are false.
When user fill data to Text1 and the data entry get validate is true, Text2 enabled set to true and so on with Text3 and Text4.
When user corrected data entry on Text2 and the data entry get validate is false, Text3, Text4 enabled property set to false but the value remain.
When user corrected data entry on Text1 and the data entry get validate is false, Text2, Text3, Text4 enabled property set to false but the value remain.
And so on.
Hope you all got my message.
-
Jul 31st, 2006, 11:22 PM
#2
PowerPoster
Re: Best Logic to solve this
where do you get the validation value?
-
Jul 31st, 2006, 11:26 PM
#3
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
-
Jul 31st, 2006, 11:30 PM
#4
PowerPoster
Re: Best Logic to solve this
i agree
-
Jul 31st, 2006, 11:31 PM
#5
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
-
Jul 31st, 2006, 11:32 PM
#6
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
Last edited by Bruce Fox; Jul 31st, 2006 at 11:38 PM.
-
Jul 31st, 2006, 11:33 PM
#7
Re: Best Logic to solve this
 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.
-
Jul 31st, 2006, 11:41 PM
#8
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
Last edited by Bruce Fox; Aug 1st, 2006 at 10:39 PM.
-
Aug 1st, 2006, 01:50 AM
#9
Thread Starter
Addicted Member
Re: Best Logic to solve this
is there any generic solution other than using array textbox when another control frame of combobox?
-
Aug 1st, 2006, 03:04 AM
#10
Re: Best Logic to solve this
 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??????
-
Aug 1st, 2006, 03:55 AM
#11
Thread Starter
Addicted Member
Re: Best Logic to solve this
sorry,
I just found out that i need using frame
-
Aug 1st, 2006, 04:33 AM
#12
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.
Last edited by Bruce Fox; Aug 1st, 2006 at 10:42 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|