Tips And Tricks
I seem to run into things from time to time that I want to share with the world,
usually things that I had to find out the hard way. Sometimes it will just be
something that I had to dig for, and want to make more readily accessible. This
page is intended to make life a little easier for other programmers. If it meets
your need, then that's what it's here for.
Turn Startup Form Off Programatically In MS Access Project
And what did I do after enumerating MS Access Project Properties? Well
after I found out the exact name of the property that I wanted to set,
I wrote the code to set it programmatically. We needed to be able to
turn off the main menu temporarily while preparing a new version. We
call the following code to turn the main menu off while setting links
and references, then, just before actually publishing the new MS Access
project (or database), we call the same code with parameters to turn the
startup menu back on. I'm sure other people have done this too, but
why strain your brain? Submitted for your perusal, a function to change
startup properties (those that return string values, anyway) in an Access
project. The code was written to run in either MS Access 2000, or MS
Access 2003. (Anyone who is paying attention may notice that this is an
adaptation of my other code to change the title of an ADP)
'Change a startup parameter -BWM 06-23-08
Function ChgStartupOpt(pPropName, pOldVal, pNewVal)
On Error GoTo ErrorHandler
Const conPropNotFoundError = 2455
Dim strCurrentValue As String
'Need to deal with "StartUpForm","Form.Login" -BWM 06-23-08
strCurrentValue = CurrentProject.Properties(pPropName) 'retrieve or gen error -BWM 09-29-06
If Len(Trim(strCurrentValue)) > 0 Or Len(Trim(strCurrentValue)) = 0 Then
CurrentProject.Properties.Remove pPropName
CurrentProject.Properties.Add pPropName, pNewVal
End If
Exit Function
ErrorHandler:
If Err.Number = conPropNotFoundError Then
CurrentProject.Properties.Add pPropName, pNewVal
Else
MsgBox "Error #" & Err.Number & ": " & Err.Description
End If
Resume Next
End Function
Sample Calls:
ChgStartupOpt("StartUpForm","Form.Login","") 'turn the main menu off
ChgStartupOpt("StartUpForm","","Form.Login") 'turn main menu back on
The first sample call was used in a RunCode Action in a macro named
"setStartMenuOff". The next action line in the macro was "Quit". The
second sample call (to turn the main menu back on), was called from a
macro called "setStartMenuOn". These macros were called from different
points in a batch file using the "/x" command line switch in Microsoft
Access. This has been a real help, because that startup form was getting
to be a nuisance during multiple executions of the program to set up
connection to the live data, change the reference for the library from
an ADP to an ADE, etc.
If you found this information to be useful,
and would like to donate via PayPal to help offset the cost of
maintaining this web site, use the following button:
|
|
|
|