470,618 Members | 1,721 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,618 developers. It's quick & easy.

SubForm Problem

DD
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
Nov 12 '05 #1
3 2856
-----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/AwUBP7n7OIechKqOuFEgEQIIjwCdHsFTMN2JCRdOfTzP5nQRR5 PX8gEAoJjI
OfgcHQoCOJoAe4IBtXXHX9Fs
=EqQB
-----END PGP SIGNATURE-----

DD wrote:
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

Nov 12 '05 #2
DD
I am still not getting it right.
MY ORIGINAL QUESTION
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

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(child) frmBuilder(Parent)

Const frmWorkSheet = "frmBuilder"

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

WHERE AM I WRONG

MGFoster <me@privacy.com> wrote in message news:<%W*****************@newsread2.news.pas.earth link.net>... -----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/AwUBP7n7OIechKqOuFEgEQIIjwCdHsFTMN2JCRdOfTzP5nQRR5 PX8gEAoJjI
OfgcHQoCOJoAe4IBtXXHX9Fs
=EqQB
-----END PGP SIGNATURE-----

DD wrote:
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

Nov 12 '05 #3
-----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!frmBuilder!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 = "frmWorkSheet"
========

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_CHILD).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/AwUBP7sFyIechKqOuFEgEQLzEQCfeFbgfr2BKZn0KOpEgPkear kvKggAnjFH
tnl29Md+KAiWww3wGMFzjtHN
=ywEB
-----END PGP SIGNATURE-----
DD wrote:
I am still not getting it right.
MY ORIGINAL QUESTION
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



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(child) frmBuilder(Parent)

Const frmWorkSheet = "frmBuilder"

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

WHERE AM I WRONG

MGFoster <me@privacy.com> wrote in message news:<%W*****************@newsread2.news.pas.earth link.net>...
-----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/AwUBP7n7OIechKqOuFEgEQIIjwCdHsFTMN2JCRdOfTzP5nQRR5 PX8gEAoJjI
OfgcHQoCOJoAe4IBtXXHX9Fs
=EqQB
-----END PGP SIGNATURE-----

DD wrote:

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

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by sixsoccer | last post: by
3 posts views Thread by Nicolae Fieraru | last post: by
6 posts views Thread by Sally | last post: by
5 posts views Thread by DS | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.