Solved

To:Bin_huwairib

Posted on 1998-06-14
2
223 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now