If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Run-time error
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_Err dbs.Properties(strPropName) = varPropValue ChangeProperty = 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 |
#2
|
|||
|
|||
Run-time error
I'm not sure what else is wrong, but you cannot use the word "AutoExec" as a
function name. It is a reserved word. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "Anthony" wrote in message ... 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_Err dbs.Properties(strPropName) = varPropValue ChangeProperty = 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 |
#3
|
|||
|
|||
Run-time error
If The code you have listed is correct, you have commented out the line where
dbs is set (two lines above the error). There is an apostrophe in front of the line. 'Set dbs = CurrentDb The object dbs never gets set. "Anthony" wrote: 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_Err dbs.Properties(strPropName) = varPropValue ChangeProperty = 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 |
#4
|
|||
|
|||
Run-time error
Jim, I don't believe it. That was it. Somehow that line got commented out.
It now works flawlessly. Thank you so much. As for "autoexec" being a reserve word, it is, BUT that tells Access to run a function when the program starts. "Jim B" wrote: If The code you have listed is correct, you have commented out the line where dbs is set (two lines above the error). There is an apostrophe in front of the line. 'Set dbs = CurrentDb The object dbs never gets set. "Anthony" wrote: 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_Err dbs.Properties(strPropName) = varPropValue ChangeProperty = 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 |
Thread Tools | |
Display Modes | |
|
|