Error in changing start up options.

S

SHIPP

i am using the following VB to change the default Start Up Options.

intx = AddAppProperty("AppTitle", dbText, "HRP Database", strFull)
intx = AddAppProperty("StartUpForm", dbText, "Switchboard", strFull)
intx = AddAppProperty("AllowBuiltInToolbars", dbBoolean, False, strFull)
intx = AddAppProperty("StartUpMenuBar", dbText, "HRP Data", strFull)

The only one that doesn't work is the last one StartUpMenuBar. When it hits
that line I get an error message saying HRP Database can't find the macro
'HRP Data".

Any ideas would be greatly appreciated.
 
6

'69 Camaro

Hi.

Ensure that the "HRP Data" custom menu bar exists in the current database
and that it is spelled correctly. Select the Tools menu -> Startup... to
display the Startup dialog window. Select the "Menu Bar:" combo box to
select the name of the custom menu, then copy the text and paste it directly
into the VBA code to ensure that it's spelled exactly the same. (Extra
spaces can accidently get typed into the text, and these can be hard to
spot.)

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
 
6

'69 Camaro

Several things could be causing the problem then. Things to check:

Do you have a database object, such as a module, macro or table, or possibly
a property or procedure that is also called "HRP Data"? Or used to be?
Does this custom menu call any macros or custom functions when a menu item
is selected?

Please paste the code for the AddAppProperty( ) function so that we can take
a look at what might be interfering with the string "HRP Data" that is sent
to it.

What value does "strFull" have when the names of the database properties are
sent to the AddAppProperty( ) function? I see that "intx" is overwritten on
each successive call to the function, except for the last one. Is it just a
throwaway value?

What happens if you replace the "HRP Data" string in the call to
AddAppProperty( ) with "(default)"?

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
 
S

SHIPP

I have checked the database closely and nothing else is called HRP Data.

Here is the code you requested.


Function AddAppProperty(strName As String, varType As Long, varValue As
Variant, strDBName As String) As Integer

Dim dbs As DAO.database
Dim prp As DAO.Property

Const conPropNotFoundError = 3270

' Set dbs = CurrentDb
Set dbs = DBEngine.Workspaces(0).OpenDatabase(strDBName)
On Error GoTo AddProp_Err
dbs.Properties(strName) = varValue

AddAppProperty = True

AddProp_Bye:
Exit Function

AddProp_Err:
If Err = conPropNotFoundError Then
Set prp = dbs.CreateProperty(strName, varType, varValue)
dbs.Properties.Append prp
Resume
Else
AddAppProperty = False
Resume AddProp_Bye
End If
End Function

strFull is the full path and name of the database I am changing the
properties in. intX is just a throw away value.
 
6

'69 Camaro

The other database (the one indicated by "strFull") is missing the custom
"HRP Data" menu. To import it, open the other database and select the File
menu -> Get External Data -> Import to open the Import dialog window.
Browse to the directory that contains the database with the "HRP Data" menu,
then select the "Import" button.

In the "Import Objects" dialog window, select the "Options" button. In the
"Import" section of the dialog window unselect the "Relationships" check
box, and select the "Menus and Toolbars" to import all of the custom menu
bars and toolbars from that database.

Close the other database, then open it again. It will now open without
displaying the "Cannot find macro 'HRP Data'" error message.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
 

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