DS said:
I'm trying to change the startup form from VBA but I keep getting the
error message "Property Not Found" How can I correct this? This code
is on a command button.
CurrentDb.Properties("StartupForm") = "DX"
If you don't already have a startup form set in that database, the
property doesn't exist yet and you have to create it. Try this
subroutine:
'----- start of code -----
Sub SetStartupForm(pstrFormName As String)
Dim db As DAO.Database
Dim strForm As String
strForm = Trim(pstrFormName)
Set db = CurrentDb
If Len(strForm) = 0 Then
' Remove current startup form.
On Error Resume Next
db.Properties.Delete "StartUpForm"
Else
On Error GoTo Err_Handler
db.Properties("StartUpForm") = strForm
End If
Exit_Point:
Set db = Nothing
Exit Sub
Err_Handler:
If Err.Number = 3270 Then
db.Properties.Append db.CreateProperty( _
"StartUpForm", dbText, strForm)
Resume Next
Else
Err.Raise Err.Number, Err.Source, Err.Description
End If
End Sub
'----- end of code -----