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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing form views via VBA

Status
Not open for further replies.

BigTeeJay

Technical User
Jun 13, 2001
106
US
Greetings,
Another question :) I am trying to setup
two buttons on my form. The purpose of them
is to change the view between single form
and datasheet for a subform of the main
form.

I had a helluva time trying to just specify
the form to VBA (tried...

forms.index("frm_subform").defaultview
forms.index("frm_Main!frm_subform").defaultview
forms("frm_subform").defaultview
forms("frm_Main!frm_subform").defaultview

...none of them worked (said VB couldnt find
the form). I originally couldnt access the
defaultview property before (wasnt listed, and
wasnt being recognized as a property).

I finally tried this statement...

Form_frm_Checkout_SUB_Srch_Cust.DefaultView = 2 'datasheet

...which results in a message that this needs
to be changed while in design view (which defeats
the purpose). I planned on repainting/updating
the sub form after changing its default view to
reflect the new view.

If I try...

frm_Checkout_SUB_Srch_Cust.DefaultView

...it says "Method or datamember not found", any
ideas why I have to prefix the name of my form
with the word "Form"?

Regards,
Travis
 
PS: I also tried to use...

DoCmd.RunCommand (acCmdDatasheetView)

...but this will only change the view for the main
form (not my subform). Which is where I was led into
the whole "Form_frm_etc" vs "frm_etc" rabbit trail
(I was trying to direct the docmd to the my subform
rather than the main form).

Any ideas on how to force this docmd to act on the
subform rather than the main form?

Travis
 
Holy crap, I figured it out. All I had to do was...

Code:
  frm_SubForm.SetFocus
  DoCmd.RunCommand (acCmdSubformDatasheet)

sorry, wish there was a way that I could delete
posts (oh well, maybe this will help someone else).

Regards all,
Travis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top