A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Run-time error



 
 
Thread Tools Display Modes
  #1  
Old October 27th, 2008, 04:29 PM posted to microsoft.public.access
Anthony
external usenet poster
 
Posts: 356
Default 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  
Old October 27th, 2008, 05:02 PM posted to microsoft.public.access
Arvin Meyer [MVP][_2_]
external usenet poster
 
Posts: 2,310
Default 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  
Old October 27th, 2008, 05:39 PM posted to microsoft.public.access
jim b
external usenet poster
 
Posts: 31
Default 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  
Old October 27th, 2008, 06:18 PM posted to microsoft.public.access
Anthony
external usenet poster
 
Posts: 356
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:36 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.