Connecting Tech Pros Worldwide Help | Site Map

Programatically Set Startup Form

PC Datasheet
Guest
 
Posts: n/a
#1: Nov 13 '05
How can I programatically set the startup form when the database opens?

Thanks!

Steve


Tim Marshall
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Programatically Set Startup Form


PC Datasheet wrote:
[color=blue]
> How can I programatically set the startup form when the database opens?
>
> Thanks!
>
> Steve[/color]

1) Thanks for your help on my sorting question

2) How about have a start up form that's not intended to be opened with
the following in the on open event. the criteria could be based on the
network user name, whether a connection to the backend is able to be
made (test with a simple recordset open), etc, etc, all run before the
air code select statement below.

dim strOpenForm as string

select case <some criteria>

case 1

stropenform = "form1"

case 2

stropenform = "form2"

case else

stropenform = "whatever"

end select

cancel = true 'cancel opening of this form (or hide it for value storage)

docmd.openform stropenForm


--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
PC Datasheet
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Programatically Set Startup Form


Tim,

Thanks for your response!

You can go to Tools -Startup and set "MyForn" to open when the database
opens, How do you do this programatically?

Steve


"Tim Marshall" <TIMMY!@PurplePandaChasers.Moertherium> wrote in message
news:djj3nv$dn5$1@coranto.ucs.mun.ca...[color=blue]
> PC Datasheet wrote:
>[color=green]
>> How can I programatically set the startup form when the database opens?
>>
>> Thanks!
>>
>> Steve[/color]
>
> 1) Thanks for your help on my sorting question
>
> 2) How about have a start up form that's not intended to be opened with
> the following in the on open event. the criteria could be based on the
> network user name, whether a connection to the backend is able to be made
> (test with a simple recordset open), etc, etc, all run before the air code
> select statement below.
>
> dim strOpenForm as string
> select case <some criteria>
>
> case 1
>
> stropenform = "form1"
>
> case 2
>
> stropenform = "form2"
>
> case else
>
> stropenform = "whatever"
>
> end select
>
> cancel = true 'cancel opening of this form (or hide it for value storage)
>
> docmd.openform stropenForm
>
>
> --
> Tim http://www.ucs.mun.ca/~tmarshal/
> ^o<
> /#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
> /^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me[/color]


Arno R
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Programatically Set Startup Form



"PC Datasheet" <nospam@nospam.spam> schreef in bericht news:Ye87f.766$AS6.59@newsread3.news.atl.earthlink .net...[color=blue]
> How can I programatically set the startup form when the database opens?
>
> Thanks!
>
> Steve [/color]

ChangeProperty "StartupForm", dbText, "YourFormName"

Private Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Boolean
Dim db As Database, prp As Property
Const conPropNotFoundError = 3270
On Error GoTo Change_Err
Set db = CurrentDb
db.Properties(strPropName) = varPropValue
ChangeProperty = True
Exit Function

Change_Err:
If Err = conPropNotFoundError Then
Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
db.Properties.Append prp
Resume Next
Else
ChangeProperty = False
Exit Function
End If
End Function

If the property does not exist yet, it will be created.

Arno R
bcanavan@bmghomes.com
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Programatically Set Startup Form


Create a macro called AutoExec.

Insert an OpenForm command, and enter the name of the form you want to
appear when Access opens.

There are many other things you can do on startup from the AutoExec
macro. Look at the command list to get an idea.

Bob

PC Datasheet
Guest
 
Posts: n/a
#6: Nov 13 '05

re: Programatically Set Startup Form


Thank you!

This falls squarely upon the intent of the newsgroups; ie, to provide help
to Access users.

Now why can't you continue to be a decent human being.

Steve


"Arno R" <arraNOcomSPAM@tiscali.nl> wrote in message
news:435d2582$0$742$5fc3050@dreader2.news.tiscali. nl...

"PC Datasheet" <nospam@nospam.spam> schreef in bericht
news:Ye87f.766$AS6.59@newsread3.news.atl.earthlink .net...[color=blue]
> How can I programatically set the startup form when the database opens?
>
> Thanks!
>
> Steve[/color]

ChangeProperty "StartupForm", dbText, "YourFormName"

Private Function ChangeProperty(strPropName As String, varPropType As
Variant, varPropValue As Variant) As Boolean
Dim db As Database, prp As Property
Const conPropNotFoundError = 3270
On Error GoTo Change_Err
Set db = CurrentDb
db.Properties(strPropName) = varPropValue
ChangeProperty = True
Exit Function

Change_Err:
If Err = conPropNotFoundError Then
Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
db.Properties.Append prp
Resume Next
Else
ChangeProperty = False
Exit Function
End If
End Function

If the property does not exist yet, it will be created.

Arno R


Arno R
Guest
 
Posts: n/a
#7: Nov 13 '05

re: Programatically Set Startup Form



"PC Datasheet" <nospam@nospam.spam> schreef in bericht news:G2b7f.18574$vw6.1877@newsread1.news.atl.earth link.net...[color=blue]
> Thank you!
>
> This falls squarely upon the intent of the newsgroups; ie, to provide help
> to Access users.[/color]


One minor adjustment:
The newsgroups intent is to provide *free* help to Access users.
[color=blue]
> Now why can't you continue to be a decent human being.[/color]

It's your turn to be decent.

Arno R
David W. Fenton
Guest
 
Posts: n/a
#8: Nov 13 '05

re: Programatically Set Startup Form


"PC Datasheet" <nospam@nospam.spam> wrote in
news:p%87f.799$AS6.503@newsread3.news.atl.earthlin k.net:
[color=blue]
> You can go to Tools -Startup and set "MyForn" to open when the
> database opens, How do you do this programatically?[/color]

Look up CUSTOM PROPERTIES in Access Help. There's code there to set
custom properties.

Keep in mind that most Access properties don't actually exist until
you set a value. Thus, you can't programmatically set the startup
form until you've actually created that property. The code example
in the help file does exactly that, with a SetCustomProperty
function that works both when the property already exists and when
it doesn't (it uses an error handler to create the property if it
doesn't yet exist).

The code for changing the the property once it's been created is
actually quite trivial:

CurrentDB.Properties("StartupForm") = "MyForm"

I'm not sure where you can get a list of the official property
names, though. You can't just loop through the Properties collection
and output the names in the Debug Window, because the properties
aren't there until a value has been set.

Here's a list of the property names for the properties in the
Startup dialog:

Application Title AppTitle
Application Icon AppIcon
Display Form/Page StartupForm
Display Database Window StartupShowDBWindow
Display Status Bar StartupShowStatusBar
Menu Bar StartupMenuBar
Shortcut Menu Bar StartupShortcutMenuBar
Allow Full Menus AllowFullMenus
Allow Default Shortcut Menus AllowShortcutMenus
Allow Built-In Toolbars AllowBuiltInToolbars
Allow Toolbar/Menu Changes AllowToolbarChanges
Allow Viewing Code After Error AllowBreakIntoCode
Use Access Special Keys AllowSpecialKeys

I suspect that comes from a help topic somewhere, but I can't locate
it -- I'm just copying this from comments I've included in code
where I set the startup properties.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
David W. Fenton
Guest
 
Posts: n/a
#9: Nov 13 '05

re: Programatically Set Startup Form


"PC Datasheet" <nospam@nospam.spam> wrote in
news:G2b7f.18574$vw6.1877@newsread1.news.atl.earth link.net:
[color=blue]
> This falls squarely upon the intent of the newsgroups; ie, to
> provide help to Access users.[/color]

You should have checked the Access help files before posting, as
Arno just quoted from the help files.
[color=blue]
> Now why can't you continue to be a decent human being.[/color]

This makes you look like a first-class asshole.

You know that this newsgroup's charter prohibits solitation, yet you
flout those rules anyway. Nonetheless, you expect to get help when
you have a problem.

While I don't think there's any point in trying to get you to stop
soliciting (it's been tried too many times in the past and you're
always too stubborn to change), I think it's pretty assholish to
solicit and then expect to be treated well by the other posters in
the newsgroup.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
loringdo
Guest
 
Posts: n/a
#10: Nov 13 '05

re: Programatically Set Startup Form


Good link to find out what the startup and other options you
programatically set.

http://msdn.microsoft.com/library/de...HV05188062.asp

loringdo
Guest
 
Posts: n/a
#11: Nov 13 '05

re: Programatically Set Startup Form


Good links to find statrup and other options you can Set or Get. Hope
this help I am sure it will.

Set Options from Visual Basic [Access 2003 VBA Language Reference]

http://msdn.microsoft.com/library/de...HV05188062.asp

Set Startup Properties from Visual Basic [Access 2003 VBA Language
Reference]

http://msdn.microsoft.com/library/de...HV05188072.asp

loringdo

Closed Thread