Tabs Conditional Navigation

jketcher

Registered User.
Local time
Today, 02:32
Joined
Apr 15, 2009
Messages
77
I need to navigate from one tab to another tab depending upon results of some If/Else code to edit combo box data. Here is the code that works to produce an error message if a user has made an invalid selection. When the msgbox pops up and the user enters ok, how can I display the correct tab for the user to enter data?

This part of the code works (thanks to lagbolt!).

If DCount("*", "Operational Review Findings", "Client = '" & Me.Client & "' AND Category = '" & Me.Category & "'") > 0 Then
cancel = True
Category.BorderColor = vbRed
MsgBox "Duplicate Record - Select the Edit Findings tab to change input for this category."

If the MsgBox pops up, the focus needs to move from Tab1 to Tab2. Can someone help me with the code to handle this?

Thank you!
 
MsgBox "Duplicate Record - Select the Edit Findings tab to change input for this category."
Me.YourTabCtlName.Pages(1).SetFocus


or you can just use Tab2's name:

MsgBox "Duplicate Record - Select the Edit Findings tab to change input for this category."
Me.Tab2Name.SetFocus
 
I entered the code you recommended and when testing got an error message to the effect

'You must save the control before you execute the GoToControl action, the GoTo Control method, or the SetFocus method.'

Here is the code I created thinking it wanted something to respond to the OK button before navigating to the new tab. But still getting errors. THe line Me.[Edit Findings].SetFocus is highlighted in yellow which indicates the error is on that line of code. Correct? Ideas?

Private Sub category_beforeupdate(cancel As Integer)
If DCount("*", "Operational Review Findings", "Client = '" & Me.Client & "' AND Category = '" & Me.Category & "'") > 0 Then
cancel = True
Category.BorderColor = vbRed
MsgBox "Duplicate Record - Select the Edit Findings tab to change input for this category."
If vbOK Then
Me.[Edit Findings].SetFocus
End If
End If
Category.BorderColor = vbBlack
End Sub
 
Did anyone get a chance to look at my last message. Still need some help. Getting a runtime error 2108. I need help handling this. Thanks so much!

jketcher:confused:
 

Users who are viewing this thread

Back
Top Bottom