Property Not Found

D

DS

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"

Thanks
DS
 
D

Dirk Goldgar

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 -----
 
D

Dirk Goldgar

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"

DS, I see you've already got an open and active thread on this issue,
with good answers in it. Frankly, I'm annoyed that you opened a new
thread on the matter, and that I spent 10 minutes out of my work day
writing a procedure for you to use. In future, please don't post
multiple messages on the same subject, unless your first post hasn't
gotten any attention in over 24 hours.
 
D

DS

Dirk said:
DS, I see you've already got an open and active thread on this issue,
with good answers in it. Frankly, I'm annoyed that you opened a new
thread on the matter, and that I spent 10 minutes out of my work day
writing a procedure for you to use. In future, please don't post
multiple messages on the same subject, unless your first post hasn't
gotten any attention in over 24 hours.
Dirk,
Please don't be annoyed as your solution was the one that worked!
Thanks
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