Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-access > #10787

Re: Form_formname method stopped working!

From Ulrich Möller <knobbi38@arcor.de>
Newsgroups comp.databases.ms-access
Subject Re: Form_formname method stopped working!
Date 2015-06-04 12:27 +0200
Organization A noiseless patient Spider
Message-ID <mkp945$s8g$1@dont-email.me> (permalink)
References <mknnv8$vfp$1@dont-email.me>

Show all headers | View raw


Am 03.06.2015 um 22:28 schrieb Neil:
> I have a database that uses a tab control in its main form. Each form 
> is a subform on a tab of the tab control, and some of those forms have 
> subforms of their own.
>
> When I want to get a value in one of the subform's subforms, rather 
> than using the Forms!form... method three levels deep, I simply use 
> the Form_formname method in my VBA code module.
>
> This has worked well. The database has been in development for several 
> months, and in all testing there were no problems.
>
> Now today, all of a sudden, it stopped working. When I do, say:
>
>     somevariable = Form_MyFormName!ID
>
> the value is returned it completely wrong. Plus, it doesn't matter 
> which record it's in; it always returns the same wrong value.
>
> Same goes for other subforms whose values I'm getting this way.
>
> I determined that what it's doing is returning values from the subform 
> as though the subform were opened on its own, not as a subform and 
> linked to the parent form and filtered for the parent form records. 
> It's like the code is just opening a copy of the subform in the 
> background and just returning the first record.
>
> This is very bizarre. Not only have I used the Form_formname method to 
> get values for a very long time, but in this database itself it has 
> been in place for a while, and has worked fine. Now all of a sudden it 
> stopped working. What happened??
>
> Any input would be GREATLY appreciated!
>
> Thanks!

Hi Neil,

the syntax Form_MyFormName is a reference to the class module of a form. 
It represents the default instance and when the class is not already 
instantiated, the form will be opened in hidden mode automatically.
This mechanism can be used for example when you want to call a public 
method in that class module but i think it is not very usefull. By the 
way, this opened form is not stored as reference in the forms collection 
so you can not use the forms("myformname").isloaded syntax for 
determining if the form is loaded or not. Indeed you must use the 
classic syntax for referencing a control on a subform like 
Forms![FormName]![SubformControName] because the default instance and 
the instance referenced in a subform.form property are not identical and 
each has its own local storage.

Ulrich


Back to comp.databases.ms-access | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Form_formname method stopped working! Neil <xxx@gmail.com> - 2015-06-03 15:28 -0500
  Re: Form_formname method stopped working! Larry Linson <larry.linson@verizon.net> - 2015-06-03 20:52 -0500
    Re: Form_formname method stopped working! Neil <nrgins@gmail.com> - 2015-06-04 05:10 -0700
  Re: Form_formname method stopped working! Ulrich Möller <knobbi38@arcor.de> - 2015-06-04 12:27 +0200
    Re: Form_formname method stopped working! Neil <nrgins@gmail.com> - 2015-06-04 05:01 -0700
      Re: Form_formname method stopped working! Ulrich Möller <knobbi38@arcor.de> - 2015-06-04 17:52 +0200
        Re: Form_formname method stopped working! Neil <xxx@gmail.com> - 2015-06-04 16:47 -0500
    Re: Form_formname method stopped working! Neil <nrgins@gmail.com> - 2015-06-04 05:40 -0700
  Re: Form_formname method stopped working! Neil <xxx@gmail.com> - 2015-06-04 09:32 -0500
    Re: Form_formname method stopped working! Larry Linson <larry.linson@verizon.net> - 2015-06-04 16:41 -0500
      Re: Form_formname method stopped working! Neil <xxx@gmail.com> - 2015-06-05 12:34 -0500
        Re: Form_formname method stopped working! Larry Linson <larry.linson@verizon.net> - 2015-06-05 23:01 -0500

csiph-web