A
Anthony
I am getting a weird run-time error. Maybe someone can help me figure out
what is happening. The run-time error I get is: "Run-time error 91"
"Object variable or With block variable not set". The error happens when
the database starts up.
When I click "End" it continues with starting up the database and doesn't
seem to affect anything.
I have several versions of the database, since I am constantly programming
new features. The odd thing about this is OLD versions of the program have
the run-time error also. Also, my colleagues that use the same version, do
NOT experience the error. Because of this, I am thinking it has nothing to
do with my code, but something with my Access startup process. That is why I
wrote this question here rather than in the Access Programming discussion
group. My startup process is somehow different than everyone else's.
Here is the offending code. In the function "Changeproperty" I have
highlighted the offending line with ">>>>"
Any help would be appreciated.
Function AutoExec()
On Error GoTo autoexec_err
DoEvents
DoCmd.Echo False
'ChangeProperty "StartupForm", dbText, "Main Menu"
ChangeProperty "StartupShowDBWindow", dbBoolean, False
ChangeProperty "StartupShowStatusBar", dbBoolean, True
ChangeProperty "AllowBuiltinToolbars", dbBoolean, False
ChangeProperty "AllowFullMenus", dbBoolean, True
ChangeProperty "AllowSpecialKeys", dbBoolean, True
DoCmd.ShowToolbar "Menu Bar", acToolbarNo
DoCmd.ShowToolbar "Database", acToolbarNo
DoCmd.ShowToolbar "Form View", acToolbarNo
DoCmd.ShowToolbar "Menu", acToolbarYes
DoCmd.ShowToolbar "Print Preview", acToolbarNo
DoCmd.ShowToolbar "Formatting (Form/Report)", acToolbarNo
'DoCmd.ShowToolbar "Find", acToolbarNo
DoCmd.Echo True
Autoexec_exit:
Exit Function
autoexec_err:
DoCmd.Echo True
MsgBox Err.Description, , Err.Number
Resume Autoexec_exit
Resume
End Function
Function ChangeProperty(strPropName As String, varPropType As Variant,
varPropValue As Variant) As Long
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270
'Set dbs = CurrentDb
On Error GoTo Change_ErrChangeProperty = True
Change_Bye:
Exit Function
Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
what is happening. The run-time error I get is: "Run-time error 91"
"Object variable or With block variable not set". The error happens when
the database starts up.
When I click "End" it continues with starting up the database and doesn't
seem to affect anything.
I have several versions of the database, since I am constantly programming
new features. The odd thing about this is OLD versions of the program have
the run-time error also. Also, my colleagues that use the same version, do
NOT experience the error. Because of this, I am thinking it has nothing to
do with my code, but something with my Access startup process. That is why I
wrote this question here rather than in the Access Programming discussion
group. My startup process is somehow different than everyone else's.
Here is the offending code. In the function "Changeproperty" I have
highlighted the offending line with ">>>>"
Any help would be appreciated.
Function AutoExec()
On Error GoTo autoexec_err
DoEvents
DoCmd.Echo False
'ChangeProperty "StartupForm", dbText, "Main Menu"
ChangeProperty "StartupShowDBWindow", dbBoolean, False
ChangeProperty "StartupShowStatusBar", dbBoolean, True
ChangeProperty "AllowBuiltinToolbars", dbBoolean, False
ChangeProperty "AllowFullMenus", dbBoolean, True
ChangeProperty "AllowSpecialKeys", dbBoolean, True
DoCmd.ShowToolbar "Menu Bar", acToolbarNo
DoCmd.ShowToolbar "Database", acToolbarNo
DoCmd.ShowToolbar "Form View", acToolbarNo
DoCmd.ShowToolbar "Menu", acToolbarYes
DoCmd.ShowToolbar "Print Preview", acToolbarNo
DoCmd.ShowToolbar "Formatting (Form/Report)", acToolbarNo
'DoCmd.ShowToolbar "Find", acToolbarNo
DoCmd.Echo True
Autoexec_exit:
Exit Function
autoexec_err:
DoCmd.Echo True
MsgBox Err.Description, , Err.Number
Resume Autoexec_exit
Resume
End Function
Function ChangeProperty(strPropName As String, varPropType As Variant,
varPropValue As Variant) As Long
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270
'Set dbs = CurrentDb
On Error GoTo Change_ErrChangeProperty = True
Change_Bye:
Exit Function
Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function