Create a StartupForm property

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

I have Access build a new database and wish to have the new database
auto-open a particular form. I am trying to do this by creating a new
property in the new db. Here's the relevant code:

Dim updaterDB as Database
Set updaterDB = OpenDatabase("MyNewDatabase")
Dim newProp as Property
Set newProp = updaterDB.Properties.CreateProperty
With newProp
.Name = "StartupForm"
.Type = 10
.Value = "Form.MainForm"
End With
updaterDB.Properties.Append (newProp)


When I get to the last line above, I get an RTE "Object Required". What am
I doing wrong?

Thanks,
 
Just use Tools, Startup to specify your startup form. No need to do it in code.
 
Actually, there is. I don't want the users to have to do it themselves
(which they'll have to under your recommendation).

I do have a correction in the code below... the fourth line should read:
Set newProp = updaterDB.CreateProperty

Thanks again,

Rob
 
Does each user have the option of starting at a different form? If so, you
need some sort of logic somewhere to determine which form gets opened,
whether it be in code or in a table. And unless I'm mistaken about Access's
startup, any logic to change the startup form can't happen until startup has
already occurred. Maybe I'm missing something. If you need each user to have
an option of what form to be presented with, even if you have a table with
userid and form name, you still have to have logic at some point to determine
that. If you have something like that, I'd create an autoexec macro that
calls a function, have that function find the appropriate startup form for
that user and then open that form.

If all users are presented with the same startup form, then Tools, Options
-> Startup is what you would use. There is no user intervention with that.
You set it yourself, then once the appl is sent to the users, the option is
already set. Maybe I don't understand what it is you're trying to do.
 
Jim,

Sorry I didn't expound much on the purpose. The idea is that the users run
some code which generates (creates) a new database. Part of that code
builds the MainForm form into the new database and *should* make the MainForm
form the Startup Form. The resulting database is used by those users and
users down the line, but I don't get involved with that process. I don't
want to force (in fact, I don't even want to *let*) the users change the
startup form. I am wary of using an autoexec macro; I think that's a clumsy
(and a bit unstable) method for doing what should be available to be done
using the Properties collection.

Thus, I think my approach is generally correct, and I'm probably only off by
a bit of syntax. I don't completely understand creating Properties in
general, but I've managed to do it in the past (for example, the same code
builds relationships in the new DB and uses the CreateProperty method to
properly connect related tables).

Thanks again for any help,
Rob
 
I think the Value parameter is simply the form name. Try

..Value = "MainForm"
 
Back
Top