Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View Subforms

Status
Not open for further replies.

icoxy

Technical User
Apr 20, 2007
11
GB
Is it possible to change the default view of a subform at runtime. I want to toggle from form view to Datasheet view?

I know this can be done using DoCmd.ViewForm, but I want a static view rather than have different windows popping up.

Is there a better way to achieve this?

Thanks

 
How are ya icoxy . . .
icoxy said:
[blue] I want to toggle from form view to Datasheet view? . . .

but I want a static view . . .[/blue]
Open the subform in [blue]design view[/blue] and set the forms [blue]Default View[/blue] property. Be sure to save before closing the form.

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Thanks Aceman. I wanted to do this at runtime using vba. Doing it this way will mean I have to duplicate every form - one saved as single form and another saved as datasheet.

Thanks,

Ian
 
Have a look at the CurrentView property of the Form object.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
icoxy . . .

Lost me with your last post. [blue]Be more specific! . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
PHV,

I tried that but, CurrentView is read only except in DesignView.

Thanks

Ian
 
Aceman,

I have a form that stays on the screen all of the time (this is the static screen). The form has some buttons that control what is displayed in the subform. I change the contents by equating RecordSource with a form name or some SQL.

As you suggest I could save each form with the CurrentView set to Form, and another version with CurrentView set to DataSheet, but I have quite a few forms so this is messy.

CurrentView is ReadOnly so I can't change the value except in the DesignView.

Any suggestions?

Thanks,

Ian
 
You can toggle a subform view between datasheet and form with:

DoCmd.RunCommand acCmdSubformDatasheet

Make sure you set focus to a control on the subform before you toggle.
 
icoxy . . .

Forgive me . . . things are still a litle vague here. [surprise]
icoxy said:
[blue]I have a form that stays on the screen all of the time (this is the static screen). [purple]The form has some buttons that control what is displayed in the subform[/purple]. I change the contents by equating RecordSource with a form name or some SQL.[/blue]
The above is indicitive of a single subform where your changing the recordsource.

[blue]Are you saying you want to change the view of the subform accordingly? . . .[/blue]

Post back the code for changing the recordsource! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
BTW whatever comes of this it looks like you'll be stuck using the following two lines:
Code:
[blue]   DoCmd.RunCommand acCmdFormView
   DoCmd.RunCommand acCmdDatasheetView[/blue]

Also, from a design point of view you can make a continuous form look just like datasheet. A form in datasheet view drops alot of form functionality! Continuous view doesn't . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
[blue]?[/blue] [surprise] . . . . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top