Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TabControl Pages: Switching is not working as desired 1

Status
Not open for further replies.

VBUser77

MIS
Jan 19, 2005
95
US
I have a tab control placed on my main form. The tabcontrol name is TabCtl and it has four pages.

When I move from Page 2 to page 3, on the TabCtl change event the following code runs:


If StR < 0 And check <> 1 Then

intMFResponse = MsgBox("Changes made to the data will result in NEGATIVE Values. Do you want to continue?", vbYesNo, "ALERT!")

If intMFResponse = vbYes Then

check = 1

GoTo Line2
ElseIf intMFResponse = vbNo Then
Forms![IOSForm]![TabCtl].Value = False
Exit Sub
End If

I do won't want to see Page 3 unless I say "Yes" to the msgbox prompt. But it takes me to page3 before I hit "yes" on the message box. Secondly if I select "No" on the message box, it takes me back to Page 1 but I like to be on Page 2: the page I was on before I tried to move to page3.

I have tried several different ways to get it working but it's not working. Any suggestions/ideas ? Thanks a lot in advance

Jay


 
to make the tab control go to a different tab use

tab_control_name.value = PageNo

do not forget that page1 = 0, page2 = 1 and so on

Hope this helps..
 
How would the code know that I was on page 0, page1 or page 2 when I tried to move to page 3. Becuase I was on page 1 instead of page 2 when I triedn to move to page 3, I like tio go back to page 1 and not page 2 when I select "No" on the message box prompt.

In other words, I like to stay on the same page I was before I tried to move to page 3 if "No" is selected.

How can I do this?

Thanks a lot for your earlier reply!

Jay
 
I have modified you code slightly, but you will need to change the tab control name and the page number in which you want to move the user to depending on the answer.

I would not concern with where the access thinks you are in the tab control, but see it has you want/need it to go to a certain page, so just tell it. Its that simple.

I hope this helps. If your still a confussed, or i've confussed you even more let me know.

Code:
If intMFResponse = vbYes Then
    
check = 1

tabcontrol.value = "2"   Go to page 3 of tab
    
GoTo Line2
ElseIf intMFResponse = vbNo Then
Forms![IOSForm]![TabCtl].Value = False

tabcontrol.value = "1"   stay on page 2 of tab

Exit Sub
End If
 
If StR < 0 And check = 0 Then

intMFResponse = MsgBox("Changes made to the Inbound/Outbound will result in NEGATIVE Storage Values. Do you want to continue?", vbYesNo, "ALERT!")

If intMFResponse = vbYes Then
Me.TabCtl.Value = "3"
check = 1

ElseIf intMFResponse = vbNo Then
check = 0
Forms![IOSForm]![TabCtl].Value = False

Exit Sub
End If


Thanks a lot for your replies. I guess I am not conveying my thoughts to you very well. Apologize for that. In the above sub procedure, if

intMFResponse = vbNo Then

"Forms![IOSForm]![TabCtl].Value = False" statement takes me back to page 0. But I don't want that. I want to go to the page I was on before I tried to move to page 3 and that page could be page 1, page 2 or page0. If it were page0, then the above statment will work fine because it takes me to page 0 but what about if i were on a different page then page0 before I tried to move to page3.

I guess what I am trying to say how can I capture the page number I was on before I moved to page 3. Once i have that information then like you said I can get back to that page if the user says "No" to the message box by hy uisng the following statement

Me.TabCtl.Value = "My Page Number I was on Before I tried to move to page 3"

I hope I make sense. Please let me know if it makes sense.

Thanks!






 
ok what you want to do is -

in your form on load procedure insert

Code:
Dim ControlValue

ControlValue = 0

Now in your change procedure in your tab control insert
Code:
If intMFResponse = vbYes Then
    
check = 1

tabcontrol.value = "2"   Go to page 3 of tab
    
GoTo Line2
ElseIf intMFResponse = vbNo Then
Forms![IOSForm]![TabCtl].Value = False

tabcontrol.value = ControlValue   goes back to previous tab page

Exit Sub
End If

controlvalue = tabcontrol.value


I have not had time to test in, but i hope you get the idea of what i am trying to do.

I will not be able to re-look at it till monday now, but have a good weekend.
 
Thanks a lot. I have figured it out what you are saying and it works . Have a great weekend!
 
Thanks M8KWR your code really helped me! I looked all over for a simple explination of how to programmatically manipulate the tab control and couldn't find any. I had 2 tab controls that I wanted to setup to interact with each other. I modified your code and placed it within a select case statement within the change events of the 2 tab control objects. It worked slick! Thanks a bunch. You deserve a star!

[2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top