Switch between datasheet mode and single form view

  • Thread starter Thread starter DontKnow
  • Start date Start date
D

DontKnow

Hi Guys,

I want to be able to select between 2 view modes - Datasheet mode and Singe
Form Mode. Currently I am using the menu toolbar via - selecting:
View,
Subform,
Form or Datasheet.

Is there any way that I can provide a pushbutton on my form that can
automatically toggle between the 2 views via code??

Cheers,

Thnaks for your assistance!!
 
DontKnow said:
Hi Guys,

I want to be able to select between 2 view modes - Datasheet mode and
Singe
Form Mode. Currently I am using the menu toolbar via - selecting:
View,
Subform,
Form or Datasheet.

Is there any way that I can provide a pushbutton on my form that can
automatically toggle between the 2 views via code??


You can't use a button, because the button wouldn't be visible in datasheet
view. You could use, say, the DblClick event of the form, which fires when
you double-click the record selector:

'----- start of example code -----
Private Sub Form_DblClick(Cancel As Integer)

If Me.CurrentView = 1 Then
RunCommand acCmdDatasheetView
Else
RunCommand acCmdFormView
End If

End Sub
'----- end of example code -----
 
Many thansk guys,

I also meant to say that the subform in datasheet mode was on a form. The
subform was on a main form. So I shall place a button on the main form to
update the subform!!

Mnay thnaks again guys Dirk and Allen!!
 
DontKnow said:
Many thansk guys,

I also meant to say that the subform in datasheet mode was on a form. The
subform was on a main form. So I shall place a button on the main form to
update the subform!!


I'm sorry, I didn't notice that you were talking about a subform. In that
case, you can use a command button on the main form, and the code would be
somewhat different (and simpler):

'----- start of code -----
Private Sub cmdToggleSubformView_Click()

Me.YourSubformName.SetFocus

RunCommand acCmdSubformDatasheet

End Sub
'----- end of code -----

For "YourSubformName", you need to substitute the name of the subform
control (on the main form), which may or may not be the same as the name of
the form object it displays.
 
Back
Top