Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change the startup form of a db with vb? 1

Status
Not open for further replies.

Emmie1

Technical User
Jun 27, 2005
11
US
Hi,
I have a database which I have written code to create a new database each month. This code works perfectly except for the need have a specific form be the startup form for the newly created database.

When I create a new month, I want the new month to have the form [BEGIN] as the startup form when the user opens the newly created database. Is there a way to do this using VB from either the old DB or the newly created DB?

Any thoughts or suggestions would be great!
Thanks in advance!
Em
 
You can set a startup form.

Code:
Public Sub SetStartForm()
   Dim dbs As Object
   Dim prp As Object
   Dim strTitle As String

   Const PROPERTY_NOT_FOUND As Integer = 3270
   Const TEXT_TYPE As Integer = 10
   ' Equivalent to DAO dbText data type.
   Const BOOL_TYPE As Integer = 1
   ' Equivalent to DAO dbBoolean data type.
   Const LONG_TYPE As Integer = 4
   ' Equivalent to DAO dbLong data type.

   On Error GoTo ErrorHandler

   Set dbs = Application.CurrentDb
   strForm = "Form1"

   ' Try to set the property. If it fails, the property does not exist.
   dbs.Properties("StartupForm") = strForm

ExitLine:
   dbs.Close
   Set dbs = Nothing
   Set prp = Nothing
   Exit Sub

ErrorHandler:
   If Err.Number = PROPERTY_NOT_FOUND Then
      ' Create the new property.
      Set prp = dbs.CreateProperty("StartupForm", TEXT_TYPE, strForm)
      dbs.Properties.Append prp
      Resume Next
   Else
      Resume ExitLine
   End If

End Sub
 
create a new database each month
Really ?
How will you make yearly or historical reports with so many DB ?
Have a look here:

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks Guys!

Remou: Do I put this code in the old DB code that creates the new database or put it somewhere so it starts up in the new Database when it's open?

PHV: Each months DB starts out with about 129K (possibly more if it's a good month!) records, which we do much manipulation through various queries and sql statement to get our end result. I create a new month each month because I am very afraid the database will become too large and cumbersome for the associates to use with 12 months of data in there (which creates another rather large problem... whining... ;-). I have an another system which gives me the history and yearly reports I need. Access is just the manipulation tool to give me the output I need to load the data into the other system.
 
You need only run it once, so run it when creating the new db. You will have to make a few changes to refer to the new db.
 
Thanks Remou, I had already started the tweaking process! It works great! You ROCK! Thanks sooooo much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top