Linked Forms?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Clive@The Coin-Op Cauldron

    #1

    Linked Forms?

    Hi all.

    I'm fairly new to access (97) programming so please forgive me if this
    has been asked a thousand times.

    I have a two forms: Form A open forms B by a button/control (form B
    enters additional information as required by the user). I need both
    forms to share the same (open) record. Form B is not a subform because
    both forms were designed independantly. Basically, the two forms cover
    all the fields of the record bewteen them and the only reason that two
    forms are being used is because of screen real estate.

    How do I pass data between the two forms and the same record without
    using Global variables or a subform?

    Thanks,
    Clive

  • PC Datasheet

    #2
    Re: Linked Forms?

    Put the following code in the click event of Form A:

    DoCmd.RunComman d acSaveRecord
    DoCmd.OpenForm "[Form B]",,,'[NameOfPKField] = " & Me!NameOfPKFiel d
    Me.Visible = False

    Put this code in Form B's AfterUpdate event:

    Forms![Form A].Requery

    Put this code in Form B's OnClose event:

    Forms![Form A].Visible = True

    When you click the button on Form A, the current record on Form A will be saved.
    This is so if you just entered data in Form A but had not yet saved the record,
    the data gets saved and shows up on Form B when it opens if any of the fields on
    Form A are also on Form B. After saving the record, the openform method opens
    Form B to the same record as Form A. Form A then becomes not visible.

    The code in Form B updates Form A everytime a record is saved including when
    Form B is closed so when Form A becomes visible it shows the data that was
    entered on Form B if Form A contains any fields that are on Form B.

    --
    PC Datasheet
    Your Resource For Help With Access, Excel And Word Applications
    resource@pcdata sheet.com



    "Clive@The Coin-Op Cauldron" <Clivejonesen@n etscape.net> wrote in message
    news:40AA95FB.8 030907@netscape .net...[color=blue]
    > Hi all.
    >
    > I'm fairly new to access (97) programming so please forgive me if this
    > has been asked a thousand times.
    >
    > I have a two forms: Form A open forms B by a button/control (form B
    > enters additional information as required by the user). I need both
    > forms to share the same (open) record. Form B is not a subform because
    > both forms were designed independantly. Basically, the two forms cover
    > all the fields of the record bewteen them and the only reason that two
    > forms are being used is because of screen real estate.
    >
    > How do I pass data between the two forms and the same record without
    > using Global variables or a subform?
    >
    > Thanks,
    > Clive
    >[/color]


    Comment

    • DMH

      #3
      Re: Linked Forms?

      On Tue, 18 May 2004 19:02:19 -0400, "Clive@The Coin-Op Cauldron"
      <Clivejonesen@n etscape.net> wrote:
      [color=blue]
      >How do I pass data between the two forms and the same record without
      >using Global variables or a subform?[/color]

      Alternatively, you can use a tab control and get almost unlimited real
      estate, and just drop fields on the pages as if it were a single form.
      The tabs all use the same recordset, so no linking or code is
      necessary.

      Comment

      • Clive@The Coin-Op Cauldron

        #4
        Re: Linked Forms?

        PC Datasheet wrote:[color=blue]
        > Put the following code in the click event of Form A:
        >
        > DoCmd.RunComman d acSaveRecord
        > DoCmd.OpenForm "[Form B]",,,'[NameOfPKField] = " & Me!NameOfPKFiel d
        > Me.Visible = False
        >
        > Put this code in Form B's AfterUpdate event:
        >
        > Forms![Form A].Requery
        >
        > Put this code in Form B's OnClose event:
        >
        > Forms![Form A].Visible = True
        >
        > When you click the button on Form A, the current record on Form A will be saved.
        > This is so if you just entered data in Form A but had not yet saved the record,
        > the data gets saved and shows up on Form B when it opens if any of the fields on
        > Form A are also on Form B. After saving the record, the openform method opens
        > Form B to the same record as Form A. Form A then becomes not visible.
        >
        > The code in Form B updates Form A everytime a record is saved including when
        > Form B is closed so when Form A becomes visible it shows the data that was
        > entered on Form B if Form A contains any fields that are on Form B.
        >[/color]

        Ah, requerying, I like that idea. Thanks, I'll give it a try!

        Clive
        [color=blue]
        > --
        > PC Datasheet
        > Your Resource For Help With Access, Excel And Word Applications
        > resource@pcdata sheet.com
        > www.pcdatasheet.com
        >
        >
        > "Clive@The Coin-Op Cauldron" <Clivejonesen@n etscape.net> wrote in message
        > news:40AA95FB.8 030907@netscape .net...
        >[color=green]
        >>Hi all.
        >>
        >>I'm fairly new to access (97) programming so please forgive me if this
        >>has been asked a thousand times.
        >>
        >>I have a two forms: Form A open forms B by a button/control (form B
        >>enters additional information as required by the user). I need both
        >>forms to share the same (open) record. Form B is not a subform because
        >>both forms were designed independantly. Basically, the two forms cover
        >>all the fields of the record bewteen them and the only reason that two
        >>forms are being used is because of screen real estate.
        >>
        >>How do I pass data between the two forms and the same record without
        >>using Global variables or a subform?
        >>
        >>Thanks,
        >>Clive
        >>[/color]
        >
        >
        >[/color]


        Comment

        • Chuck Van Den Corput

          #5
          Re: Linked Forms?

          >How do I pass data between the two forms and the same record without[color=blue]
          >using Global variables or a subform?[/color]

          Look into using OpenArgs. When form A opens form B, you can use open
          args to effectively pass a parameter. When form B opens, it can read
          the contents of OpenArgs.

          Chuck

          Comment

          Working...