On Current Type mismatch error

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
 
D

Dirk Goldgar

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])
 
S

Stefan Hoffmann

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 <--
 

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