Changing Form View with VBA

C

Chegu Tom

I have a form (with a subform) that opens in datasheet view. Working in
Access 2000

I would like to use a click or double click event to switch to form view
and back to datasheet of the open form

I can't find the object or method to do this.

Thanks
 
D

Dirk Goldgar

Chegu Tom said:
I have a form (with a subform) that opens in datasheet view. Working in
Access 2000

I would like to use a click or double click event to switch to form view
and back to datasheet of the open form

I can't find the object or method to do this.


It's not obvious. For a main form, you could write this code in the
appropriate event:

'----- start of code -----
If Me.CurrentView = 1 Then
RunCommand acCmdDatasheetView
Else
RunCommand acCmdFormView
End If

'----- end of code -----

For a subform -- if you want to switch the subform *only* between form view
and datasheet view -- the simple statement "RunCommand acCmdSubformDatasheet
toggles between form view and datasheet view of the subform. But you have
to make sure the focus is on the subform you want to affect, like so:

Me.sfMySubform.SetFocus
RunCommand acCmdSubformDatasheet
 
C

Chegu Tom

Dick

"It's not obvious" you say!

That's why people like you are so valuable. Thanks for being here!

Tom
 

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