open form in datasheet view

  • Thread starter Slez via AccessMonster.com
  • Start date
S

Slez via AccessMonster.com

I'm trying to open a form in datasheet view. The Default View is set to
Datasheet. When I open the form on its own, it opens in datasheet view as
desired. But when I open via command button on another form, it opens in
Single Form view.

How do I get it to open in datasheet view with the command button?
Thanks in advance!
 
F

fredg

I'm trying to open a form in datasheet view. The Default View is set to
Datasheet. When I open the form on its own, it opens in datasheet view as
desired. But when I open via command button on another form, it opens in
Single Form view.

How do I get it to open in datasheet view with the command button?
Thanks in advance!

Regardless of a form's default view setting, to open a form in
datasheet view from a code event you must specify datasheet view:

DoCmd.OpenForm "FormName", acFormDS
 
S

Slez via AccessMonster.com

That works as intended. Thanks!

If I could ask a follow up question to this...
I tried a DoCmd.MoveSize... method after the DoCmd.OpenForm... method in the
OnClick event of the command button as well as in the form's Open event, but
it maximizes regardless. How and where should the MoveSize command be
located?

Thanks again!
Slez
I'm trying to open a form in datasheet view. The Default View is set to
Datasheet. When I open the form on its own, it opens in datasheet view as
[quoted text clipped - 3 lines]
How do I get it to open in datasheet view with the command button?
Thanks in advance!

Regardless of a form's default view setting, to open a form in
datasheet view from a code event you must specify datasheet view:

DoCmd.OpenForm "FormName", acFormDS
 
G

Guest

Since the MoveSize method applies to the current form, you need to move it to
the form you are opening. Which event you put it in depends on when you want
it to execute. I would suggest the form Activate event. That way, if you
change to another form or open a report, it will be resized when the form
again becomes the active form.
--
Dave Hargis, Microsoft Access MVP


Slez via AccessMonster.com said:
That works as intended. Thanks!

If I could ask a follow up question to this...
I tried a DoCmd.MoveSize... method after the DoCmd.OpenForm... method in the
OnClick event of the command button as well as in the form's Open event, but
it maximizes regardless. How and where should the MoveSize command be
located?

Thanks again!
Slez
I'm trying to open a form in datasheet view. The Default View is set to
Datasheet. When I open the form on its own, it opens in datasheet view as
[quoted text clipped - 3 lines]
How do I get it to open in datasheet view with the command button?
Thanks in advance!

Regardless of a form's default view setting, to open a form in
datasheet view from a code event you must specify datasheet view:

DoCmd.OpenForm "FormName", acFormDS
 
S

Slez via AccessMonster.com

I tried this in both the Activate and Open events, but it doesn't seem to
recognize it. I don't understand why, because I have numerous other forms
with this and it works perfectly in every one. I'll post my code here in
case you see anything wrong with it. Otherwise, is there another property
that would override this command? It seems as though the issue has something
to do with the command button, because the MoveSize is successful when
opening the form on its own.

Private Sub Form_Open(Cancel As Integer)
DoCmd.MoveSize 5880, 200, 6660, 8616
End Sub

Also, here is the code for the command button. Do you see anything wrong
with that? I used the wizard, except for the addition of the datasheet line.

Private Sub cmdOpenInactive_Click()
On Error GoTo Err_cmdOpenInactive_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmUpdateInactive"
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.OpenForm "frmUpdateInactive", acFormDS

Exit_cmdOpenInactive_Click:
Exit Sub

Err_cmdOpenInactive_Click:
MsgBox Err.Description
Resume Exit_cmdOpenInactive_Click

End Sub

Thanks once again!
Slze
Since the MoveSize method applies to the current form, you need to move it to
the form you are opening. Which event you put it in depends on when you want
it to execute. I would suggest the form Activate event. That way, if you
change to another form or open a report, it will be resized when the form
again becomes the active form.
That works as intended. Thanks!
[quoted text clipped - 17 lines]
 
G

Guest

Sorry to be so long getting back. I just did some testing. I find that
MoveSize does not work if the form is maximized. If you put a Docmd.Restore
just before it, it will revert to the saved size then size to the MoveSize
parameters.
--
Dave Hargis, Microsoft Access MVP


Slez via AccessMonster.com said:
I tried this in both the Activate and Open events, but it doesn't seem to
recognize it. I don't understand why, because I have numerous other forms
with this and it works perfectly in every one. I'll post my code here in
case you see anything wrong with it. Otherwise, is there another property
that would override this command? It seems as though the issue has something
to do with the command button, because the MoveSize is successful when
opening the form on its own.

Private Sub Form_Open(Cancel As Integer)
DoCmd.MoveSize 5880, 200, 6660, 8616
End Sub

Also, here is the code for the command button. Do you see anything wrong
with that? I used the wizard, except for the addition of the datasheet line.

Private Sub cmdOpenInactive_Click()
On Error GoTo Err_cmdOpenInactive_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmUpdateInactive"
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.OpenForm "frmUpdateInactive", acFormDS

Exit_cmdOpenInactive_Click:
Exit Sub

Err_cmdOpenInactive_Click:
MsgBox Err.Description
Resume Exit_cmdOpenInactive_Click

End Sub

Thanks once again!
Slze
Since the MoveSize method applies to the current form, you need to move it to
the form you are opening. Which event you put it in depends on when you want
it to execute. I would suggest the form Activate event. That way, if you
change to another form or open a report, it will be resized when the form
again becomes the active form.
That works as intended. Thanks!
[quoted text clipped - 17 lines]
DoCmd.OpenForm "FormName", acFormDS
 
S

Slez via AccessMonster.com

Ditto on taking long before getting back. Busy week! I added DoCmd.Restore
before the MoveSize method in the forms On Open event. It now resizes as
desired when opened via the command button, but then the form that my command
button is on reduces in size from its normal maximized position. Any idea
what would cause this or how to combat it?
Slez
Sorry to be so long getting back. I just did some testing. I find that
MoveSize does not work if the form is maximized. If you put a Docmd.Restore
just before it, it will revert to the saved size then size to the MoveSize
parameters.
I tried this in both the Activate and Open events, but it doesn't seem to
recognize it. I don't understand why, because I have numerous other forms
[quoted text clipped - 44 lines]
 
G

Guest

Can't do it without it in front of me to play with. What you are discribing
may not be possible. Access has it's own ideas about how and when forms
should resized. You just have to play with it until you get it like you want
it.
--
Dave Hargis, Microsoft Access MVP


Slez via AccessMonster.com said:
Ditto on taking long before getting back. Busy week! I added DoCmd.Restore
before the MoveSize method in the forms On Open event. It now resizes as
desired when opened via the command button, but then the form that my command
button is on reduces in size from its normal maximized position. Any idea
what would cause this or how to combat it?
Slez
Sorry to be so long getting back. I just did some testing. I find that
MoveSize does not work if the form is maximized. If you put a Docmd.Restore
just before it, it will revert to the saved size then size to the MoveSize
parameters.
I tried this in both the Activate and Open events, but it doesn't seem to
recognize it. I don't understand why, because I have numerous other forms
[quoted text clipped - 44 lines]
DoCmd.OpenForm "FormName", acFormDS
 

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