SubForm Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DD

    #1

    SubForm Problem

    I want to link a form to another form by a Cmd Button.
    CustomerID = CustomerID
    I want the form to open from the Cmd Button as if it was acting in the
    same way as subform
    What would be the code? as Access dose not show you.
    DD
  • MGFoster

    #2
    Re: SubForm Problem

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Actually, there are examples in the Help files (if you can find them).
    Anyway...

    Private Sub cmdOpen_Click()

    Const FORM_SUB = "frmMyOtherForm "

    DoCmd.OpenForm FORM_SUB, _
    WhereCondition: ="CustomerID =" & Me!CustomerID

    End Sub

    Change the FORM_SUB constant to the name of the form you want to open.
    You'll need a control named "CustomerID " on the main form (it can
    have property Visible=False). This control should have a value before
    the "Open" CommandButton is clicked.

    See the Help files on the "OpenForm method."

    HTH,

    MGFoster:::mgf
    Oakland, CA (USA)
    -----BEGIN PGP SIGNATURE-----
    Version: PGP for Personal Privacy 5.0
    Charset: noconv

    iQA/AwUBP7n7OIechKq OuFEgEQIIjwCdHs FTMN2JCRdOfTzP5 nQRR5PX8gEAoJjI
    OfgcHQoCOJoAe4I BtXXHX9Fs
    =EqQB
    -----END PGP SIGNATURE-----

    DD wrote:
    [color=blue]
    > I want to link a form to another form by a Cmd Button.
    > CustomerID = CustomerID
    > I want the form to open from the Cmd Button as if it was acting in the
    > same way as subform
    > What would be the code? as Access dose not show you.
    > DD[/color]


    Comment

    • DD

      #3
      Re: SubForm Problem

      I am still not getting it right.
      MY ORIGINAL QUESTION
      I want to link a form to another form by a Cmd Button.[color=blue][color=green]
      > > CustomerID = CustomerID
      > > I want the form to open from the Cmd Button as if it was acting in the
      > > same way as subform
      > > What would be the code? as Access dose not show you.
      > > DD[/color][/color]



      The form Opens ok but is not displaying that it is linked to the
      BuilderID
      (OPENS A FORM WITH NO LINK)

      Here is what i have written in the CmdOpen Click

      frmWorkSheet(ch ild) frmBuilder(Pare nt)

      Const frmWorkSheet = "frmBuilder "

      DoCmd.OpenForm "frmWorkShe et", , , Forms![frmWorkSheet] =
      "SitesID=" & Me!BuilderID, acWindowNormal

      WHERE AM I WRONG



      MGFoster <me@privacy.com > wrote in message news:<%Wmub.468 9$sb4.4383@news read2.news.pas. earthlink.net>. ..[color=blue]
      > -----BEGIN PGP SIGNED MESSAGE-----
      > Hash: SHA1
      >
      > Actually, there are examples in the Help files (if you can find them).
      > Anyway...
      >
      > Private Sub cmdOpen_Click()
      >
      > Const FORM_SUB = "frmMyOtherForm "
      >
      > DoCmd.OpenForm FORM_SUB, _
      > WhereCondition: ="CustomerID =" & Me!CustomerID
      >
      > End Sub
      >
      > Change the FORM_SUB constant to the name of the form you want to open.
      > You'll need a control named "CustomerID " on the main form (it can
      > have property Visible=False). This control should have a value before
      > the "Open" CommandButton is clicked.
      >
      > See the Help files on the "OpenForm method."
      >
      > HTH,
      >
      > MGFoster:::mgf
      > Oakland, CA (USA)
      > -----BEGIN PGP SIGNATURE-----
      > Version: PGP for Personal Privacy 5.0
      > Charset: noconv
      >
      > iQA/AwUBP7n7OIechKq OuFEgEQIIjwCdHs FTMN2JCRdOfTzP5 nQRR5PX8gEAoJjI
      > OfgcHQoCOJoAe4I BtXXHX9Fs
      > =EqQB
      > -----END PGP SIGNATURE-----
      >
      > DD wrote:
      >[color=green]
      > > I want to link a form to another form by a Cmd Button.
      > > CustomerID = CustomerID
      > > I want the form to open from the Cmd Button as if it was acting in the
      > > same way as subform
      > > What would be the code? as Access dose not show you.
      > > DD[/color][/color]

      Comment

      • MGFoster

        #4
        Re: SubForm Problem

        -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1

        You are using the Constant incorrectly. Do not put quotes around the
        name of the Constant. You do not need to include the name of the
        child form in the WhereCondition parameter. You do not need to
        explicitly set the WindowMode parameter to acWindowNormal because that
        is the default setting.

        ==

        Since you want the child form snyched with the parent form you will
        have to have the child form's RecordSource something like this (should
        be one line):

        SELECT * FROM <table/query name> WHERE SitesID =
        Forms!frmBuilde r!SitesID

        Put in the table/query name the child form uses.

        There must be a control on the parent form named SitesID.

        ==

        Put the child form Constant declaration in the Declarations section of
        the parent form's module.

        Const FORM_CHILD = "frmWorkShe et"
        ========

        Private Sub cmdChild_Click( )
        DoCmd.OpenForm FORM_CHILD
        End Sub

        When the parent form moves to another record/closes the child form
        must be "notified." This can be accomplished by putting the
        appropriate code in the parent form's OnCurrent and OnClose events.

        == air code ==

        Private Sub Form_Current()

        On Error Resume Next

        Forms(FORM_CHIL D).Requery

        End Sub

        Private Sub Form_Close()

        On Error Resume Next

        DoCmd.Close acForm, FORM_CHILD

        End Sub

        HTH,

        MGFoster:::mgf
        Oakland, CA (USA)

        -----BEGIN PGP SIGNATURE-----
        Version: PGP for Personal Privacy 5.0
        Charset: noconv

        iQA/AwUBP7sFyIechKq OuFEgEQLzEQCfeF bgfr2BKZn0KOpEg PkearkvKggAnjFH
        tnl29Md+KAiWww3 wGMFzjtHN
        =ywEB
        -----END PGP SIGNATURE-----


        DD wrote:[color=blue]
        > I am still not getting it right.
        > MY ORIGINAL QUESTION
        > I want to link a form to another form by a Cmd Button.
        >[color=green][color=darkred]
        >>>CustomerID = CustomerID
        >>>I want the form to open from the Cmd Button as if it was acting in the
        >>>same way as subform
        >>>What would be the code? as Access dose not show you.
        >>>DD[/color][/color]
        >
        >
        >
        >
        > The form Opens ok but is not displaying that it is linked to the
        > BuilderID
        > (OPENS A FORM WITH NO LINK)
        >
        > Here is what i have written in the CmdOpen Click
        >
        > frmWorkSheet(ch ild) frmBuilder(Pare nt)
        >
        > Const frmWorkSheet = "frmBuilder "
        >
        > DoCmd.OpenForm "frmWorkShe et", , , Forms![frmWorkSheet] =
        > "SitesID=" & Me!BuilderID, acWindowNormal
        >
        > WHERE AM I WRONG
        >
        >
        >
        > MGFoster <me@privacy.com > wrote in message news:<%Wmub.468 9$sb4.4383@news read2.news.pas. earthlink.net>. ..
        >[color=green]
        >>-----BEGIN PGP SIGNED MESSAGE-----
        >>Hash: SHA1
        >>
        >>Actually, there are examples in the Help files (if you can find them).
        >> Anyway...
        >>
        >>Private Sub cmdOpen_Click()
        >>
        >> Const FORM_SUB = "frmMyOtherForm "
        >>
        >> DoCmd.OpenForm FORM_SUB, _
        >> WhereCondition: ="CustomerID =" & Me!CustomerID
        >>
        >>End Sub
        >>
        >>Change the FORM_SUB constant to the name of the form you want to open.
        >> You'll need a control named "CustomerID " on the main form (it can
        >>have property Visible=False). This control should have a value before
        >>the "Open" CommandButton is clicked.
        >>
        >>See the Help files on the "OpenForm method."
        >>
        >>HTH,
        >>
        >>MGFoster:::mg f
        >>Oakland, CA (USA)
        >>-----BEGIN PGP SIGNATURE-----
        >>Version: PGP for Personal Privacy 5.0
        >>Charset: noconv
        >>
        >>iQA/AwUBP7n7OIechKq OuFEgEQIIjwCdHs FTMN2JCRdOfTzP5 nQRR5PX8gEAoJjI
        >>OfgcHQoCOJoAe 4IBtXXHX9Fs
        >>=EqQB
        >>-----END PGP SIGNATURE-----
        >>
        >>DD wrote:
        >>
        >>[color=darkred]
        >>>I want to link a form to another form by a Cmd Button.
        >>>CustomerID = CustomerID
        >>>I want the form to open from the Cmd Button as if it was acting in the
        >>>same way as subform
        >>>What would be the code? as Access dose not show you.
        >>>DD[/color][/color][/color]


        Comment

        Working...