Posted on 1998-06-14
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Author Comment

ID: 1463261
Edited text of question

Accepted Solution

bin_huwairib earned 100 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month3 days, 13 hours left to enroll

630 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