Solved

To:Bin_huwairib

Posted on 1998-06-14
2
232 Views
Last Modified: 2010-05-03
Hi morning Bin_huwairib,
QUESTION:
   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:
Question:
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.......

REFERENCE:
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.

Question:
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  
 
ssptkt,

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.

Example
=======
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...

Comment
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".
Thanks
 
 
 
   
 
 
 
 
 
 
 

0
Comment
Question by:ssptkt
2 Comments
 

Author Comment

by:ssptkt
ID: 1463261
Edited text of question
0
 
LVL 5

Accepted Solution

by:
bin_huwairib earned 100 total points
ID: 1463262
ssptkt,

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
 Next
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
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
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…

831 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