Toggling views in subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have tried to apply a suggestion from another post, but cant get this to
work. I wish to have a button on a main form that toggles the view of a
subform between continuous form view and datasheet view. The following, of
which, was posted in a previous thread, is what i have tried:

Select Case Screen.ActiveForm.CurrentView
Case 1
' Currently in form view
RunCommand acCmdDatasheetView
Case 2
' Currently in datasheet view
RunCommand acCmdFormView
Case Else
' Must be design view (0) or some as yet undefined view
' Do nothing.
End Select
 
You'll need to do something like this:

Me.SubFormName.SetFocus
DoCmd.RunCommand acCmdSubformDatasheet
 
I've got a main form, with a subform that in turn has two subforms. If the
command button is on the main form, and I use the code just as you have
written below, then the command sets the sub-subform to list view, rather
than my subform. If I modify the code to set the focus first on the main
form, then change the view, I get the error:

"Run-time error 2046: The command or action 'SubformDatasheetView' isn't
available now."

Wazzup?

I'd appreciate any help.

Danny
 
Back
Top