On Current Type mismatch error

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I have a Tab-Control with 5 tabs each with a differnt sub-form. On the On
Current event of each of the subforms, I want to use the following

=CheckEditingLevel([Forms]![Maintain Car]![cntPAActions])

to call the Function below. Unfortunately, I get the following error when I
move to the next record.

"The expression On Current you entered as the event property setting
produced the following error" Type mismatch." What's wrong??? Is it
something to do with the TabControl object???


Called Function
**********************************************
Function CheckEditingLevel(frmFormName As Form)
On Error GoTo Err_Form_Load
'**************************************************************************************
'Name: CheckEditingLevel
'Purpose: This Function set the formss "Allow" setting based on the users
Access Level.
'Author: Chris Premo
'Date: September 29, 2009
'Called by: This function is called by the Form's "OnLoad" event.
'**************************************************************************************

'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
frmFormName.AllowAdditions = True
frmFormName.AllowDeletions = True
frmFormName.AllowEdits = True
End If

Exit_Form_Load:
Exit Function

Err_Form_Load:
MsgBox Error$
Resume Exit_Form_Load

End Function
 
Chris said:
I have a Tab-Control with 5 tabs each with a differnt sub-form. On the On
Current event of each of the subforms, I want to use the following

=CheckEditingLevel([Forms]![Maintain Car]![cntPAActions])

to call the Function below. Unfortunately, I get the following error when
I
move to the next record.

"The expression On Current you entered as the event property setting
produced the following error" Type mismatch." What's wrong??? Is it
something to do with the TabControl object???


Called Function
**********************************************
Function CheckEditingLevel(frmFormName As Form)
On Error GoTo Err_Form_Load
'**************************************************************************************
'Name: CheckEditingLevel
'Purpose: This Function set the formss "Allow" setting based on the
users
Access Level.
'Author: Chris Premo
'Date: September 29, 2009
'Called by: This function is called by the Form's "OnLoad" event.
'**************************************************************************************

'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
frmFormName.AllowAdditions = True
frmFormName.AllowDeletions = True
frmFormName.AllowEdits = True
End If

Exit_Form_Load:
Exit Function

Err_Form_Load:
MsgBox Error$
Resume Exit_Form_Load

End Function


If "cntPAActions" is the name of a subform control (on the main form), you
need to pass the function the control's .Form property. For example:

=CheckEditingLevel([Forms]![Maintain Car]![cntPAActions].[Form])

If this expression is in the Current event of each of the individual subform
controls' SourceObject form, then you can drop the reference to the main
form and pass a simple reference to the .Form property:

=CheckEditingLevel([Form])
 
hi Chris,
**********************************************
Function CheckEditingLevel(frmFormName As Form)
On Error GoTo Err_Form_Load
'**************************************************************************************
'Name: CheckEditingLevel
'Purpose: This Function set the formss "Allow" setting based on the users
Access Level.
'Author: Chris Premo
'Date: September 29, 2009
'Called by: This function is called by the Form's "OnLoad" event.
'**************************************************************************************

'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
frmFormName.AllowAdditions = True
frmFormName.AllowDeletions = True
frmFormName.AllowEdits = True
End If

Exit_Form_Load:
Exit Function

Err_Form_Load:
MsgBox Error$
Resume Exit_Form_Load

End Function
I would rewrite this function:

Public Function SetEditingLevel(AForm As Form, _
AAccessLevel As Long _
) As Boolean

On Local Error GoTo LocalError

Dim Allow As Boolean

Allow = Not (AAccessLevel > 1)

AForm.AllowAdditions = Allow
AForm.AllowDeletions = Allow
AForm.AllowEdits = Allow

SetEditingLevel = True
Exit Funciton

LocalError:
MsgBox Err.Description
SetEditingLevel = False

End Function


mfG
--> stefan <--
 
Back
Top