views:

1102

answers:

1

This seems like it would be a simple affair, and I am sure I have done this before, but it has been a while since I have done any UI programming in Access. What I need to do is put a button on a form to toggle between datasheet and form view for a subform.

I have found a defaultview property, but nothing that looks like it would toggle the view of the form after it is already open.

Essentially I need the property I can fill in the following code..

sfEmployeeBatchEntry.Form.??? = acFormDS
+2  A: 

I found it on my own. I was missing it because it used the silly and clunky RunCommand syntax instead of a simple property or method on the control or form classes.

It ain't pretty, but for posterity, here is the answer.

'You have to set focus to the subform control or the change view call will'
'fail (UGH!)'
MyForm.mySubFormControl.SetFocus

'Change to datasheet view...'
DoCmd.RunCommand acCmdSubformDatasheet

'Change to Form View...'
DoCmd.RunCommand acCmdSubformFormView
JohnFx