Open Datasheets in order

ECEK

Registered User.
Local time
Today, 23:46
Joined
Dec 19, 2012
Messages
717
I have five datasheet forms that open autoexec.
I'm trying to open them in order so they sit correctly at the top of the page but I then to set the focus to the first form that was opened.

Code:
DoCmd.OpenForm "frmForm1", acFormDS, "", "", , acNormal
DoCmd.OpenForm "frmForm2", acFormDS, "", "", , acNormal
DoCmd.OpenForm "frmForm3", acFormDS, "", "", , acNormal
DoCmd.OpenForm "frmForm4", acFormDS, "", "", , acNormal
DoCmd.OpenForm "frmForm5", acFormDS, "", "", , acNormal
Forms!frmForm1!ID.SetFocus

I tried this but my reference seems to be out !!
Any thoughts?
 
Got it !!!!

Forms!frmForm1.SetFocus
 
However !!!!!
It doesn't work when I change the Form view to acNormal.
My solution was to just repeat the open form line for the form i wanted to get focus
 
sorry but what is acNormal?
 
As arnelgp has mentioned, for that position it should be acWindowNormal ?
acNormal is the second parameter where you have acFormsDS ?
 
Sorry that was a little ambiguous
This is my code now. as you can the Form1 is duplicated.
Code:
    DoCmd.OpenForm "frmForm1", acNormal, "", "", , acNormal
    DoCmd.OpenForm "frmForm2", acNormal, "", "", , acNormal
    DoCmd.OpenForm "frmForm3", acNormal, "", "", , acNormal
    DoCmd.OpenForm "frmForm4", acNormal, "", "", , acNormal
    DoCmd.OpenForm "frmForm1", acNormal, "", "", , acNormal
 
So when you switch forms programatically, how does Access know which Form1 to select?
 
As already stated, your code should have been:

Code:
DoCmd.OpenForm "frmForm1", acNormal, "", "", , acWindowNormal
(etc)

BUT the two arguments used are both defaults & can be omitted along with the empty strings, so this can be reduced to
Code:
DoCmd.OpenForm "frmForm1"

You could of course have just reversed the order
Code:
DoCmd.OpenForm "frmForm5"
DoCmd.OpenForm "frmForm4"
DoCmd.OpenForm "frmForm3"
DoCmd.OpenForm "frmForm2"
DoCmd.OpenForm "frmForm1"

But do you really need the overhead of having 5 open form?
Much better to open each form as needed e.g. button in form1 to open form2 etc
 

Users who are viewing this thread

Back
Top Bottom