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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

751 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