Prevent Tab Control until required fields completed on Tabbed Forms

Rx_

Nothing In Moderation
Local time
Today, 00:31
Joined
Oct 22, 2009
Messages
2,803
In Tabbed Forms - what is the best way to prevent a user from clicking another tab?

A Tab Control with several forms.
One form has an edit for 3 fields. A process is in place to ensure the combination of the 3 are unique in the DB.
There is a boolean flag to indicate when the user task is in process or completed.

Can't seem to find any code that keeps the user on the single tab form and prevents them from bailing out mid-way.
 
Perhaps you could use your boolean flag to determine which pages are visible, and thus available for selection by your user.
 
The Tabbed Control Change event fires anytime the Tabbed Pages change. But to base something on the change event, you have to identify the particular page that has focus. I think something like this would work for you. It assumes that the Page you want the user to complete before moving to any other Page is the First Page, and that the boolean flag is named BFlag:

Code:
Private Sub YourTabbedControl_Change()
  
  Select Case YourTabbedControl
    
    Case 0  'First Page
     'No code here; this is where the three required fields reside
    
    Case 1  'Second page
      If BFlag <> True Then
       MsgBox "You Must Complete the Three Fields on Page One!"
       YourTabbedControl.Pages(0).SetFocus
      End If
     
    Case 2  'Third page
      If BFlag <> True Then
       MsgBox "You Must Complete the Three Fields on Page One!"
       YourTabbedControl.Pages(0).SetFocus
      End If
  End Select

End Sub
Linq ;0)>
 
Perfect! Was looking for a Cancel event, but could not find one.
This will be just perfect for my requirement.
Spent 45 minutes searching the Internet and could not find this solution with key words.
Thank you very much!
 
Glad we could help!

Good luck with your project!

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom