on open

  • Thread starter Thread starter mb
  • Start date Start date
M

mb

Hi,

I have two questions about the On Open event of the
form. I would like the form to maximize upon open. I am
looking for suggestions on how to do this.

Also, the first field in the form is an auto-populated
date, so I would also like the cursor to appear in the
second field on the form upon open.

I think I would use the On Open event of the form, but I
do not know how to write the code to do these things.

I would greatly appreciate any ideas!
 
To maximize the form use the following code:

Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
End Sub

Private Sub Form_Close()
DoCmd.Restore
End Sub

This will maximise on open and restore on close (Restore on close or all
windows will be maximised when the form is closed)

You can use "Tab Order" to specify which control box is selected on open.
Remove any entries from the Tab Index property if you don't want a field
selected.
 
Open the form in Design view.
Open the Properties window for the form.
Click on the Events tab.
Right-click in the OnOpen line and select Build.
When the ChooseBuilder window opens, select Code Builder. This will open VB.
Enter the code listed below:

Private Sub Form_Open (Cancel As Integer)

' maximize form
DoCmd.Maximize

' set cursor to specified control
txtTextBox2.SetFocus

End Sub

Hope this helps!

Howard Brody
 
For your first question, create a macro called something
like "Max". There should be one command in this macro -
Maximize. Once you've created the macro, select that
macro as the action to take "on open" on the form's
properties. One thing to keep in mind, from then on all
forms will be maximized when opened until the file is
closed or a command is given to "restore" a form. I
usually put the maximize command in an autoexec macro so
that all forms will be maximized when opened.

For your second question, I would suggest setting the Tab
stop property for the date field to "no". Check the "Tab
order" for the form (under the "View" menu choice) to make
sure the second field you refer to is the first one on
that list.
 
Yes, use the On Open event and create an event procedure.

Type in the following:

DoCmd.Maximize
me.Fieldname.Setfocus


Hope this helps...
 
Create an Event Procedure.

Type Docmd.maximize

(When you type the period, a dropdown will appear and as
you type maximize it will find it.)

Compile, Save and your form will maximize on open.

On the field properties for your date field, select Yes
for AutoTab. Your new record will autofill the field and
autotab sends your cursor to the next field when the input
field is filled. Just have your desired field next in tab
order after the autofilled date field.

Hope it helps!
 
For your first question, create a macro with one command
in it - Maximize. On your form, select the newly created
macro as the event to run "On open" in the properties for
the form. Keep in mind, after you do this, all forms will
be maximized until you close the file or "restore" a
form. I usually add the maximize command to an autoexc
macro so that all forms will be maximized whenever I open
a file.

For your second question, on the properties for the date
field, change the Tab stop from "yes" to "no". Then check
the tab order (from the View menu) and make sure the field
you want the cursor in is the first on the tab order list.
 
Thank you for your ideas!

I can create the macro in the "On open" event, but how do
I write the code involved.

I understand the second answer.

Thanks again!
 
Back
Top