Groups | Search | Server Info | Login | Register


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

Re: Determine what the main form

From <martin@hotmail.com>
Newsgroups comp.databases.ms-access
References (1 earlier) <e02fp6dn4e6kgtdhks53vco0glp6ue0s3q@4ax.com> <ec1hp6l81blguig61j2o6a1f4n54jh94v7@4ax.com> <93chp6131b9kr3v4ni76rmrcr6ajapjijt@4ax.com> <v8dhp61kd7rldh1taloi0ejhfpfscpuelf@4ax.com> <o5rhp6tp3sj48efg2n9mout2hrcd5ps7k8@4ax.com>
Subject Re: Determine what the main form
Date 2011-04-04 17:00 +0200
Message-ID <9c54a$4d99dcfe$5356be6c$32716@cache120.multikabel.net> (permalink)
Organization Multikabel

Show all headers | View raw


I managed to make this subform work. I did have to set the child and 
masterfields in the main form's load event. It works well.

One of the reasons for doing this was to save an almost identical form. And 
if I change something in the code I only have to do it once. Also I have a 
lot of code in the subform, with direct references to the form, which would 
take me quite a while to migrate to a module.

The subform is a standard subform that holds hyperlink values related to the 
mainform. It is expected to work for different main form in the same manner.

Martin


"Marshall Barton"  schreef in bericht 
news:o5rhp6tp3sj48efg2n9mout2hrcd5ps7k8@4ax.com...

Arsene@selenium.net wrote:

>On Sun, 03 Apr 2011 12:53:32 -0500, Marshall Barton
><marshbarton@wowway.com> wrote:
>
>>Arsene@selenium.net wrote:
>>
>>>On Sat, 02 Apr 2011 15:38:24 -0500, Marshall Barton wrote:
>>>
>>>><martin@hotmail.com> wrote:
>>>>
>>>>>I have a subform which I've always used in one main form. Now I would 
>>>>>like
>>>>>to use the same subform in another main form, only the subform then 
>>>>>needs a
>>>>>different record source and the behavior of the subform should at some
>>>>>points be slightly different which I'm planning to do in VBA.
>>>>>
>>>>>My questions are: how can I check in my subform by which mainform it is
>>>>>opened? And secondly: can I safely use the subform in 2 mainforms at 
>>>>>the
>>>>>same time?
>>>>
>>>>
>>>>Sure you can do that.  You can check the name of the main
>>>>form:
>>>>
>>>>Select Case Parent.Name
>>>>Case "main form 1"
>>>>   ...
>>>>Case "main form 2"
>>>>   ...
>>>>Case Else
>>>>   MsgBox "wrong main form or not a subform"
>>>>End Select
>>>
>>>
>>>So, in order to share one subform among multiple mainforms, should the
>>>above code (Select Case Parent.Name, etc.) be inserted in the
>>>subform's "On Load" event?
>>
>>
>>If you really need the subform to act differently in
>>different main forms, then you can put that kind of code
>>anywhere you need to figure out which main form it's in.
>>
>>Don't forget that subforms are opened before the main form
>>so don't try to do it too early in the subform.  I think the
>>Load even should be OK but double check it.
>>
>>I would try to avoid this kind of thing and serioously
>>consider the tradeoffs of doing this vs creating separate
>>subforms.
>
>I have always created separate, dedicated subforms for each mainform,
>which has thus far worked OK, witht he only drawback it sometimes (in
>larger applications) results in the creation of a lot of forms, which
>I was trying to avoid (as one of several ways to decrease file size),
>but perhaps you are right and it might not be worth it for the
>relatively minuscule decrease in file size.
>

File size is not a significant tradeoff factor.  I think the
major consideration is the maintence confusion of dealing
with several nearly identical form objects vs the difficulty
of keeping things straight in one complex form object.  All
I'm saying is that it is something to think about.

--
Marsh 

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


Thread

Determine what the main form <martin@hotmail.com> - 2011-04-02 22:03 +0200
  Re: Determine what the main form Marshall Barton <marshbarton@wowway.com> - 2011-04-02 15:38 -0500
    Re: Determine what the main form <martin@hotmail.com> - 2011-04-03 10:36 +0200
    Re: Determine what the main form Arsene@selenium.net - 2011-04-03 09:42 -0500
      Re: Determine what the main form Marshall Barton <marshbarton@wowway.com> - 2011-04-03 12:53 -0500
        Re: Determine what the main form Arsene@selenium.net - 2011-04-03 13:01 -0500
          Re: Determine what the main form Marshall Barton <marshbarton@wowway.com> - 2011-04-03 17:23 -0500
            Re: Determine what the main form <martin@hotmail.com> - 2011-04-04 17:00 +0200
              Re: Determine what the main form Marshall Barton <marshbarton@wowway.com> - 2011-04-04 11:33 -0500
            Re: Determine what the main form Arsene@selenium.net - 2011-04-08 09:33 -0500

csiph-web