Improve company productivity with a Business Account.Sign Up



Posted on 1998-06-14
Medium Priority
Last Modified: 2010-05-03
Hi morning Bin_huwairib,
   I've got an add on doubts to the reference below. If each of my panels now contain two more mask edit controls besides the 4 text boxes that I have intially. How should I modify the function or the codes which you had provided earlier on. Validation would still be the same. That is my mask1 must be filled before mask2, and mask2 must be filled before text1, and text1 must be filled before text2 and so on.....
Perhaps it would be clearer if you were to look at the following:
Panel 1:  mask1 mask2 text1  text2 text3 text4
Panel 2:  mask3 mask4 text5  text6 text7 text8
Panel 15: mask31 mask32 text57text58text59text60
Could you please advise me. Please be assured that I would email 100 points to you for this doubt. THank you and have a nice day.
  oh sorry!just one more comment to add.That is at the same time, panel one must first be filled before panel two, and panel two before panel three and so on.......

Hi Bin,
  still remember about the case where each panel contain 4 textboxes. This is an add on to that question.
I have now 15 panels and each panel still contain 4 text boxes. How can I modify the function which have provided me earlier on to cater for the below question whereby the rules still remains.

Panel 1:   text1  text2 text3 text4
Panel 2:   text5  text6 text7 text8
Panel 15:  text57text58text59text60
How can I make sure that at least one of the textboxes in panel one must be filled before my user can enter data onto the textboxes of the second panel.Similarly at least one text box of panel 2 must be filled before user are allow to enter data onto text boxes of panel 3. (Note: sqeuence within the textboxes of each panel is still important,anyway this has been enlightened by you).Thanks.
Accepted Answer
From: bin_huwairib Date: Monday, May 25 1998 - 09:58PM PDT  

As I understood from your question that you want the user to be able to fill a textbox in a panel incase of at least one textbox was filled in the previous panel.

If my idea were correct then I would like to remind you about one rule that is in a panel the user can't fill a textbox unless the previous textbox is filled. So we are sure that the first textbox in any panel will be filled always and based on this rule we can build our checking.

Don't change any thing in your application, just add the textboxes keypress event for the first textbox in each panel except the first panel.

Private Sub MaskEdBox5_KeyPress(KeyAscii As Integer)
 If MaskEdBox1.Text = "" Then
  MsgBox "You must fill at least one field in the previous panel."
  KeyAscii = 0
 End If
End Sub

Private Sub MaskEdBox9_KeyPress(KeyAscii As Integer)
 If MaskEdBox5.Text = "" Then
  MsgBox "You must fill at least one field in the previous panel."
  KeyAscii = 0
 End If
End Sub

Private Sub MaskEdBox57_KeyPress(KeyAscii As Integer)
 If MaskEdBox53.Text = "" Then
  MsgBox "You must fill at least one field in the previous panel."
  KeyAscii = 0
 End If
End Sub

Best regards
Bin Huwairib
Question History:  
Accepted Answer
From: bin_huwairib Date: Monday, May 25 1998 - 09:58PM PDT  

Text above...

From: ssptkt Date: Monday, May 25 1998 - 11:16PM PDT  
Hi Brother,
   How come I didn't think of that before. Only after you had mentioned then I realised. Anyway,real grateful to your prompt reply. I am very sure in no time you would be the top few in the list. Best wishes to you.
By the way any more comments on the question regarding "suppressing ODBC logon screen".

Question by:ssptkt

Author Comment

ID: 1463261
Edited text of question

Accepted Solution

bin_huwairib earned 200 total points
ID: 1463262

I think it is becoming much complex than before!! :)

Anyway, I did some enhancement in the function. Here it is.

Function PrevFields_OK(CurIndex As Integer, ContainerName As String) As Boolean
 Dim MyControl As Control
 Dim I As Integer
 Dim Found As Boolean

 Found = False
 PrevFields_OK = True
 For Each MyControl In Controls
  If (TypeOf MyControl Is MaskEdBox) Or (TypeOf MyControl Is TextBox) Then
   If MyControl.Container.Name = ContainerName Then
    If MyControl.Tag = CurIndex - 1 Then
     If MyControl.Text = "" Then
      MsgBox "You must fill field no." & MyControl.Tag & " first."
      PrevFields_OK = False
     End If
     Found = True
     Exit For
    End If
   End If
  End If
End Function

Private Sub Form_Load()
 MaskEdBox1.Tag = "1"
 MaskEdBox2.Tag = "2"
 Text1.Tag = "3"
 Text2.Tag = "4"
 Text3.Tag = "5"
 Text4.Tag = "6"
 MaskEdBox3.Tag = "1"
 MaskEdBox4.Tag = "2"
 Text5.Tag = "3"
 Text6.Tag = "4"
 Text7.Tag = "5"
 Text8.Tag = "6"
End Sub

Private Sub MaskEdBox2_KeyPress(KeyAscii As Integer)
 If Not PrevFields_OK(MaskEdBox2.Tag, MaskEdBox2.Container.Name) Then KeyAscii = 0
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
 If Not PrevFields_OK(Text1.Tag, Text1.Container.Name) Then KeyAscii = 0
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
 If Not PrevFields_OK(Text2.Tag, Text2.Container.Name) Then KeyAscii = 0
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)
 If Not PrevFields_OK(Text3.Tag, Text3.Container.Name) Then KeyAscii = 0
End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)
 If Not PrevFields_OK(Text4.Tag, Text4.Container.Name) Then KeyAscii = 0
End Sub

Private Sub MaskEdBox4_KeyPress(KeyAscii As Integer)
 If Not PrevFields_OK(MaskEdBox4.Tag, MaskEdBox4.Container.Name) Then KeyAscii = 0
End Sub
Private Sub Text8_KeyPress(KeyAscii As Integer)
 If Not PrevFields_OK(Text8.Tag, Text8.Container.Name) Then KeyAscii = 0
End Sub

Best regards
Bin Huwairib

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

587 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question