Tab Form Control - On Click Action

C

Chris

I have a form ([Maintain CARS]) with a control form ([cntForm]) that has 5
tabs. I want to have an on_click call to a Module on each of the tabs. When
I place the command "=MessageMaintainCARS()" in the onclick event of each of
the Tabs and open the form and click nothing happens. What am I missing?
 
M

Mark Andrews

If you are using a tab control with 5 tabs then:
How about using the After_update event of the tab control and determining
which tab is choosen by the value of the tab control.

Not sure what control Form is?
Mark
 
L

Linq Adams via AccessMonster.com

This kind of thing is done using the OnChange event. The code would be
something like this:

Private Sub YourTabbedControlName_Change()

Select Case Me.YourTabbedControlName.Value
Case 0
MsgBox "1st Page"

Case 1
MsgBox "2nd Page"
Case 2
MsgBox "3nd Page"
End Select

End Sub

Just replace the Msgbox code with code to run your module.
 
C

Chris

Thanks for the reply. I stumbled upon that after I made this post. Now I
have a followup. I use the following Fucntion to display a message box on
the main form if the selected tab-Sub-form is empty. It works if I'm logged
in with access level 1, but if I'm logged in with 2 or > then nothing. I
watch the process blow right past the " If IsNull(Forms![MAINTAIN
CAR]![cntPAActions].Form![INV_RPT_ACTION]) Then" statement and go the the
"Else" part. Previously I had used this code to lock the user's rights on
the form.

*******************************************
'This procedure checks the users access level as
'defined in the "tblPasswordTable" table. The Main Menu
If Forms![Main Menu]![AccessLevel] > 1 Then
frmFormName.AllowAdditions = False
frmFormName.AllowDeletions = False
frmFormName.AllowEdits = False
Else
End If
********************************************


THIS IS THE CODE I CAN'T SEEM TO GET TO WORK RIGHT.
*********************************************
Function MessageMaintainCARS()
On Error GoTo Err_MessageMaintainCAR
'**************************************************************************************
'Name: MessageMaintainCARS
'Purpose: This function is used to display a message when no record shows in
' the related sub-form.
'
'Author: Chris Premo
'Date: October 23, 2009
'Called by: This function is called by the "On Change" event of the "cntForm"
' Tab Control form on the "Maintain CARS" form
'**************************************************************************************

'This procedure enables a message for users not able to edit the data.
'The message tells the user that no sub-form record exists for the
current case.
If Forms![Main Menu]![AccessLevel] > 1 Then

'Control number for cmdPAAcction
If Forms![MAINTAIN CAR]!cntForm.Pages(0).Visible = True And
Forms![MAINTAIN CAR]!cntForm.Value = 0 Then
If IsNull(Forms![MAINTAIN
CAR]![cntPAActions].Form![INV_RPT_ACTION]) Then
Forms![MAINTAIN CAR]![ErrorMsg].Visible = True
Forms![MAINTAIN CAR]![ErrorMsg].Caption = "No PA Action
Record Exists for this Case!"
Else
Forms![MAINTAIN CAR]![ErrorMsg].Visible = False
End If
'Control number for cmdSearchWarrant
ElseIf Forms![MAINTAIN CAR]!cntForm.Pages(1).Visible = True And
Forms![MAINTAIN CAR]!cntForm.Value = 1 Then
Forms![MAINTAIN CAR]![cntWarrants].Visible = True
If IsNull(Forms![MAINTAIN CAR]![cntWarrants]) Then
Forms![MAINTAIN CAR]![ErrorMsg].Visible = True
Forms![MAINTAIN CAR]![ErrorMsg].Caption = "No Search Warrant
Record Exists for this Case!"
Else
Forms![MAINTAIN CAR]![ErrorMsg].Visible = False
End If
'Control number for cmdViolations
ElseIf Forms![MAINTAIN CAR]!cntForm.Pages(2).Visible = True And
Forms![MAINTAIN CAR]!cntForm.Value = 2 Then
If IsNull(Forms![MAINTAIN CAR]![cntViolations].Form![VIOL_CD])
Then
Forms![MAINTAIN CAR]![ErrorMsg].Visible = True
Forms![MAINTAIN CAR]![ErrorMsg].Caption = "No Violation
Record Exists for this Case!"
Else
Forms![MAINTAIN CAR]![ErrorMsg].Visible = False
End If
'Control number for cmdArrests
ElseIf Forms![MAINTAIN CAR]!cntForm.Pages(3).Visible = True And
Forms![MAINTAIN CAR]!cntForm.Value = 3 Then
If IsNull(Forms![MAINTAIN
CAR]![cntArrests].Form![cARREST_SURREND]) Then
Forms![MAINTAIN CAR]![ErrorMsg].Visible = True
Forms![MAINTAIN CAR]![ErrorMsg].Caption = "No Arrest Record
Exists for this Case!"
Else
Forms![MAINTAIN CAR]![ErrorMsg].Visible = False
End If
'Control number for cmdDisposition
ElseIf Forms![MAINTAIN CAR]!cntForm.Pages(4).Visible = True And
Forms![MAINTAIN CAR]!cntForm.Value = 4 Then
If IsNull(Forms![MAINTAIN CAR]![cntDisposition].Form![disp_cd
lookup]) Then
Forms![MAINTAIN CAR]![ErrorMsg].Visible = True
Forms![MAINTAIN CAR]![ErrorMsg].Caption = "No Disposition
Record Exists for this Case!"
Else
Forms![MAINTAIN CAR]![ErrorMsg].Visible = False
End If
Else
End If
Else
End If

Exit_MessageMaintainCARS:
Exit Function

Err_MessageMaintainCARS:
MsgBox Error$
Resume Exit_MessageMaintainCARS

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top