Form to open on startup

  • Thread starter Thread starter David H
  • Start date Start date
Go up to the menu bar and select:
Tools--Startup--"Display Form"

Select your form from the list.
 
Thanks

Can I do this without displaying the Access interface?

David Hanmer
Access Novice!

Jeff Conrad said:
Go up to the menu bar and select:
Tools--Startup--"Display Form"

Select your form from the list.
 
Hi David,
Can I do this without displaying the Access interface?

Sure, but it will require some additional setup.

1. Create a new standard module and copy/paste this code:

Public Function funcSetStartupForm( _
strForm As String)
On Error GoTo ErrorPoint

CurrentDb().Properties("StartupForm") = _
strForm

ExitPoint:
Exit Function

ErrorPoint:
If Err = 3270 Then
' Property was not found
Dim db As DAO.Database
Dim prop As DAO.Property
Set db = CurrentDb()
Set prop = db.CreateProperty("StartupForm", _
dbText, "(none)")
db.Properties.Append prop
Resume Next
End If

End Function

2. Make sure to set a reference to the DAO object library
if you are using Access 2000 or 2002 (97 or 2003 should
already be set).

3. Compile the code and save the module as
modSetStartUpForm

4. Create a new form called frmSetStartupForm. Add a combo
box and put these settings on it:

- Name: cboSelectForm
- Row Source Type: Table/Query
- Row Source: SELECT MsysObjects.Name
FROM MsysObjects
WHERE (((Left$([Name],1))<>"~") AND ((MsysObjects.Type)=-
32768))
ORDER BY MsysObjects.Name;
- Column Count: 1
- Bound Column: 1
- Limit To List: Yes

Adjust any size/formatting to your desire.

This combo box will display a list of all your form names.

5. Now add a command button to the form called
cmdSetStartupForm and add this code to the click event:

Private Sub cmdSetStartupForm_Click()
On Error GoTo ErrorPoint

Dim strForm As String

If IsNull(Me.cboSelectForm) Then
MsgBox "Please select a form " _
& "from the list before continuing." _
, vbInformation, "Which Form?"
GoTo ExitPoint
End If

strForm = Me.cboSelectForm

funcSetStartupForm (strForm)

ExitPoint:
Exit Sub

ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & _
Err.Description, vbExclamation, _
"Unexpected Error"
Resume ExitPoint

End Sub

Make any size/formatting changes to the command button as
you desire.

6. Compile the code, make any formatting changes to the
form, save, and then close the form.

7. Now test it out. Open the form, select a form name from
the combo box and then hit the command button. The StartUp
Form property should then change to the selection you
made. Close the database and then re-open to fully test.

That should do it I believe.
David Hanmer
Access Novice!

Access Novice?!
Well you should join our Access Anonymous club then!
This week's special guest speaker will be MVP Albert
Kallal leading a discussion entitled "To Merge or not to
Merge, that is the question."
 
Back
Top