• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

Prevent double message or fix coding to Prevent moving to another tab page

I have coding in the TabControl page under ON CHANGE to test if a certain field is filled.  If the field is not filled it gives a message like:

"The Event Date needs to be filled"

then it returns to the original tab.  

My problem is when it returns to the original tab it repeats the message because the ON CHANGE is working again.  How can I either prevent the second message or is there a way that it will not even let you click the other tabs until certain fields are full.. I guess, if possible I can disable the other tabs until the fields are complete?
0
Shaft960
Asked:
Shaft960
  • 4
  • 2
  • 2
1 Solution
 
peter57rCommented:
Hi Shaft960,
You could check  for the tab you are selecting and ignore the test if it is the page the required field is on.

If Me.mytab.Pages(Me.mytab).Caption = "something" Then
' do nothing
Else
'test required field

End If

Pete
0
 
Shaft960Author Commented:
I can't seem to get it.. I dont know if I have this right...

If Me.TabCtl100.Pages(0).Caption = "Event Information" Then
' do nothing
Else
'test
end if

My tab is named EVENT INFORMATION and I didn't have a caption but I put one in called EVENT INFORMATION.

Where does this code go in the ON CHANGE OF THE TAB CONTROL?
0
 
Shaft960Author Commented:
what is replaced by mytab
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
Shaft960Author Commented:
I cant get it to work
0
 
Shaft960Author Commented:
my coding must be wrong.. it is a good idea that you had though
0
 
peter57rCommented:
mytab is the name of the tab control.

Pete
0
 
puppydogbuddyCommented:
Shaft960,
Try placing this code in the change event of your tab control, and modify it to your specs:

Private Sub TabCtl100_Change()
On Error GoTo Error_Routine

Select Case Me.TabCtl100.Value
    Case Is = 0   'run code for page1<<<< Me.Page1.PageIndex = 0
        If Me.Page1.Caption = "Event Information" then
                Me.Dirty = False             'commit changes
        Else
                'field validation
        End If
        TabCtl100.Pages.Item(0).SetFocus
    Case Is = 1   'run code for page2<<<< Me.Page2.PageIndex = 1
         blah blah

        TabCtl100.Pages.Item(1).SetFocus
    Case Is = 2   'run code for page3<<<< Me.Page3.PageIndex = 2
       
           blah blah

         TabCtl100.Pages.Item(2).SetFocus
End Select
0
 
puppydogbuddyCommented:
oops' didn't refresh my browser
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now