Form State


M

Michael

I have a form where the user enters data. There is button that tunrs
the form into a datasheet view incase the use likes to see it that way
instead. Problem is when the user closes the datasheet view with the
'x' button the single form is gone too. I am looking for a way to find
out the state of the form so that if it is in datasheet view I can use
the on close property to open it back up in single form (default)
view.

Any help would be appreciated.

Thank,

Michael
 
Ad

Advertisements

T

Tom van Stiphout

On Mon, 22 Jun 2009 14:02:00 -0700 (PDT), Michael <[email protected]>
wrote:

That would be somewhat difficult to do because when the form is
closed, its code is gone too. So we need to open the bag of tricks.

Trick 1: Use the Form_Unload event and cancel closing the form if
needed:
Private Sub Form_Unload(Cancel As Integer)
If Me.CurrentView = 2 Then
Cancel = True
RunCommand acCmdFormView
End If
End Sub
Alas, in my testing this did not work: can't switch to this view at
this time.

Trick 2: Use another helper form. In this scenario when the form is
about to close and is in Datasheet mode, another always running,
perhaps invisible form's timer is started. It looks at a global
variable which was set to the name of the closing form. Every second
it checks for the form no longer being in the Forms collection, and if
so it starts the form in Form view.

-Tom.
Microsoft Access MVP
 
Ad

Advertisements

M

Michael

That would be somewhat difficult to do because when the form is
closed, its code is gone too. So we need to open the bag of tricks.

Trick 1: Use the Form_Unload event and cancel closing the form if
needed:
Private Sub Form_Unload(Cancel As Integer)
    If Me.CurrentView = 2 Then
        Cancel = True
        RunCommand acCmdFormView
    End If
End Sub
Alas, in my testing this did not work: can't switch to this view at
this time.

Trick 2: Use another helper form. In this scenario when the form is
about to close and is in Datasheet mode, another always running,
perhaps invisible form's timer is started. It looks at a global
variable which was set to the name of the closing form. Every second
it checks for the form no longer being in the Forms collection, and if
so it starts the form in Form view.

-Tom.
Microsoft Access MVP





- Show quoted text -

Is their no way to just turn datasheet view back into normal view?
 

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