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?
Shaft960Asked:
Who is Participating?
 
peter57rConnect With a Mentor Commented:
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
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.