Using Access 2007 ... I know how to set the default (startup) form using the "Access Options" dialog (Current Database tab). Easy. However, I now find myself using VBA to construct a new .accdb file - I am copying tables (+relationships) into it fine, and I can also copy Forms. However, having set up this new .accdb file I now want to set one of the Forms as being the startup form, from my VBA code.
I have an open access object in my code, and I'm hoping that there is a property somewhere (under CurrentProject perhaps) that I can set, but I've been hunting for a while now and can't find it.
Can anyone point me towards the right answer?
(Yes, I know I can also copy Macros into my file and I could create one called AutoExec but the reason for not wanting to do this would make this a very long post indeed....)
Dim dbs As DAO.Database
Dim pty As DAO.Property
Set dbs = CurrentDb
Set pty = dbs.CreateProperty("StartupForm", dbText, "Form1")
Set pty = Nothing
Set dbs = Nothing