Setting Startup Form

D

DS

I have a form set to open on startup, however I want to change that form
to another form after some initial info has been filled out. I put this
code attached to a command button on the original startup form, but it
doesn't seem to be working...

CurrentDB.Properties("StartupForm") = "DX"

Any help appreciated.
Thank you.
DS
 
D

DS

Jeff said:
A startup form is just that, what you get when you start up.

If you have a button on your startup form that you want to use to open
another form, try:

DoCmd.OpenForm (see Access HELP for syntax)
Perhaps you misunderstood me. I have a startup form. The next time I
open the Access database I want a different startup form and I want to
change that using VBA on a command button.
Thanks
DS
 
B

Barry Gilbert

By default, this property is not a part of the properties collection. You'll
need to add it first, using the CreateProperties method.

HTH,
Barry
 
D

DS

Barry said:
By default, this property is not a part of the properties collection. You'll
need to add it first, using the CreateProperties method.

HTH,
Barry


:
Thank you.
How is this done?
DS
 
D

DS

DS said:
Thank you.
How is this done?
DS
I have this code, but I keep getting "dbtext not defined"...
Thanks
DS

Private Sub Command7_Click()
ChangeProperty "StartupForm", dbtext, "DX"
End Sub
Private Function ChangeProperty(strPropName As String, varPropType As
Variant, varPropValue As Variant) As Boolean
Dim db As Database, prp As Property
Const conPropNotFoundError = 3270
On Error GoTo Change_Err
Set db = CurrentDb
db.Properties(strPropName) = varPropValue
ChangeProperty = True
Exit Function

Change_Err:
If Err = conPropNotFoundError Then
Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
db.Properties.Append prp
Resume Next
Else
ChangeProperty = False
Exit Function
End If
End Function
 
B

Barry Gilbert

I'm not sure why it doesn't recognize dbText; it's just a constant.

The code you have is generic, to allow modification of any property of any
type. If you're only using it for the Startup property, you could hard-code
all the variables to simplify it.

Barry
 
J

Jeff Conrad

The code posted is DAO code so you are missing a reference to the DAO
object library. Add a reference to the DAO 3.6 Object Library and you
should be fine.

If you're using both ADO and DAO code in this database then change the
code to this so Access does not get confused:

' *****Start of revised code****
Private Sub Command7_Click()
ChangeProperty "StartupForm", dbText, "DX"
End Sub

Private Function ChangeProperty(strPropName As String, varPropType As Variant, _
varPropValue As Variant) As Boolean

Dim db As DAO.Database
Dim prp As DAO.Property
Const conPropNotFoundError = 3270

On Error GoTo Change_Err

Set db = CurrentDb

db.Properties(strPropName) = varPropValue
ChangeProperty = True

Exit Function

Change_Err:
If Err = conPropNotFoundError Then
Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
db.Properties.Append prp
Resume Next
Else
ChangeProperty = False
Exit Function
End If

End Function
' *****End of revised code****

--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:
 
D

DS

Jeff said:
The code posted is DAO code so you are missing a reference to the DAO
object library. Add a reference to the DAO 3.6 Object Library and you
should be fine.

If you're using both ADO and DAO code in this database then change the
code to this so Access does not get confused:

' *****Start of revised code****
Private Sub Command7_Click()
ChangeProperty "StartupForm", dbText, "DX"
End Sub

Private Function ChangeProperty(strPropName As String, varPropType As Variant, _
varPropValue As Variant) As Boolean

Dim db As DAO.Database
Dim prp As DAO.Property
Const conPropNotFoundError = 3270

On Error GoTo Change_Err

Set db = CurrentDb

db.Properties(strPropName) = varPropValue
ChangeProperty = True

Exit Function

Change_Err:
If Err = conPropNotFoundError Then
Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
db.Properties.Append prp
Resume Next
Else
ChangeProperty = False
Exit Function
End If

End Function
' *****End of revised code****
Thanks Jeff, I understand now. I appreciate the help.
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top