Change view

  • Thread starter Thread starter rob p
  • Start date Start date
R

rob p

I have a form (frmclient) used to enter / edit / add to a table (tblclient).
I also want this to be available in datasheet view. What's easier, just
having two forms each with a different default view or is there a way to use
a command button to change the view or maybe another way? Thanks.
 
Hi Rob

You should be able to switch between views using this code:

If Me.CurrentView = acCurViewFormBrowse Then
Me.CurrentView = acCurViewDatasheet
Else
Me.CurrentView = acCurViewFormBrowse
End If

Personally, I avoid datasheet view and instead use a continuous form. These
are much easier to format the way you want, and can contain headers and
footers with command buttons and other controls. For this, of course, you
would need to create two forms - one for single record details and one for
"list view".
 
According to Access 2000 Help, CurrentView is a read-only property.
Has this changed in later versions?

Graham Mandeno said:
Hi Rob

You should be able to switch between views using this code:

If Me.CurrentView = acCurViewFormBrowse Then
Me.CurrentView = acCurViewDatasheet
Else
Me.CurrentView = acCurViewFormBrowse
End If

Personally, I avoid datasheet view and instead use a continuous form. These
are much easier to format the way you want, and can contain headers and
footers with command buttons and other controls. For this, of course, you
would need to create two forms - one for single record details and one for
"list view".
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

rob p said:
I have a form (frmclient) used to enter / edit / add to a table
(tblclient).
I also want this to be available in datasheet view. What's easier, just
having two forms each with a different default view or is there a way to
use
a command button to change the view or maybe another way? Thanks.
 
To be honest, I don't know. Like I said, I avoid datasheet view.

However, this should certainly work:

If Me.CurrentView = acCurViewFormBrowse Then
DoCmd.RunCommand acCmdDatasheetView
Else
DoCmd.RunCommand acCmdViewFormView
End If

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

MacDermott said:
According to Access 2000 Help, CurrentView is a read-only property.
Has this changed in later versions?

Graham Mandeno said:
Hi Rob

You should be able to switch between views using this code:

If Me.CurrentView = acCurViewFormBrowse Then
Me.CurrentView = acCurViewDatasheet
Else
Me.CurrentView = acCurViewFormBrowse
End If

Personally, I avoid datasheet view and instead use a continuous form. These
are much easier to format the way you want, and can contain headers and
footers with command buttons and other controls. For this, of course,
you
would need to create two forms - one for single record details and one
for
"list view".
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

rob p said:
I have a form (frmclient) used to enter / edit / add to a table
(tblclient).
I also want this to be available in datasheet view. What's easier, just
having two forms each with a different default view or is there a way
to
use
a command button to change the view or maybe another way? Thanks.
 
Back
Top