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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set start up properties from vba?

Status
Not open for further replies.

DRH192

Programmer
Apr 25, 2005
96
GB
is it possible to set the name of the start up form from vba?

many thanks
 
Some notes.


Code:
Public Sub SetStartForm()
   Dim dbs As Object
   Dim prp As Object
   
   Const PROPERTY_NOT_FOUND As Integer = 3270
   Const TEXT_TYPE As Integer = 10
   ' Equivalent to DAO dbText data type.

   On Error GoTo ErrorHandler

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

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, "frmForm")
      dbs.Properties.Append prp
      Resume Next
   Else
      Resume ExitLine
   End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top