Programatically Set Startup Form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • PC Datasheet

    #1

    Programatically Set Startup Form

    How can I programatically set the startup form when the database opens?

    Thanks!

    Steve


  • Tim Marshall

    #2
    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

    Comment

    • PC Datasheet

      #3
      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!@PurpleP andaChasers.Moe rtherium> 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]


      Comment

      • Arno R

        #4
        Re: Programatically Set Startup Form


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

        ChangeProperty "StartupFor m", dbText, "YourFormNa me"

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

        Change_Err:
        If Err = conPropNotFound Error Then
        Set prp = db.CreateProper ty(strPropName, varPropType, varPropValue)
        db.Properties.A ppend 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

        Comment

        • bcanavan@bmghomes.com

          #5
          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

          Comment

          • PC Datasheet

            #6
            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@dr eader2.news.tis cali.nl...

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

            ChangeProperty "StartupFor m", dbText, "YourFormNa me"

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

            Change_Err:
            If Err = conPropNotFound Error Then
            Set prp = db.CreateProper ty(strPropName, varPropType, varPropValue)
            db.Properties.A ppend 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


            Comment

            • Arno R

              #7
              Re: Programatically Set Startup Form


              "PC Datasheet" <nospam@nospam. spam> schreef in bericht news:G2b7f.1857 4$vw6.1877@news read1.news.atl. earthlink.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

              Comment

              • David W. Fenton

                #8
                Re: Programatically Set Startup Form

                "PC Datasheet" <nospam@nospam. spam> wrote in
                news:p%87f.799$ AS6.503@newsrea d3.news.atl.ear thlink.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 programmaticall y set the startup
                form until you've actually created that property. The code example
                in the help file does exactly that, with a SetCustomProper ty
                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.Prope rties("StartupF orm") = "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 StartupShowDBWi ndow
                Display Status Bar StartupShowStat usBar
                Menu Bar StartupMenuBar
                Shortcut Menu Bar StartupShortcut MenuBar
                Allow Full Menus AllowFullMenus
                Allow Default Shortcut Menus AllowShortcutMe nus
                Allow Built-In Toolbars AllowBuiltInToo lbars
                Allow Toolbar/Menu Changes AllowToolbarCha nges
                Allow Viewing Code After Error AllowBreakIntoC ode
                Use Access Special Keys AllowSpecialKey s

                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

                Comment

                • David W. Fenton

                  #9
                  Re: Programatically Set Startup Form

                  "PC Datasheet" <nospam@nospam. spam> wrote in
                  news:G2b7f.1857 4$vw6.1877@news read1.news.atl. earthlink.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

                  Comment

                  • loringdo

                    #10
                    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

                    Comment

                    • loringdo

                      #11
                      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

                      Comment

                      Working...