473,508 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2971
-----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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
680
by: sixsoccer | last post by:
I have built a database with a <Mainform> and a <Subform>. My problem is twofold. 1. My subform is set as a continuos form with AllowAddiotions set to NO (ie. a list of Issues to the client on...
25
10167
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
5
3361
by: Bob | last post by:
Hi Everybody I have a form called frmListBox that is connected to a table tblListBox. This is opened from a form called "frmInvoiceOrder" which has a subform called "zfrmInvoiceOrder" and...
1
2490
by: Traci | last post by:
My problem is in a form/subform. On the main form I have an unbound listbox named OptionsInPlan. In the OnCurrent event of the main form I set the value of the listbox with the code:...
3
4483
by: Nicolae Fieraru | last post by:
Hi All, I have a problem and I can't figure out how to solve it. My database has three tables: tblCustomers, with CustomerId and CustomerName tblProducts, with ProductId and ProductCode...
4
6969
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
6
3910
by: Sally | last post by:
I need to be able to click in a subform and run code but at the same time I need to be able to scroll the records without running the code. I tried coding the Enter event of the subform control but...
5
1507
by: DS | last post by:
I have a form with 2 Subforms...The first subform is linked to the main form. The second Subform is liked to the first subform. Whenever I add a record to the first subform that works fine. When...
9
9667
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
11
7130
by: mrowe | last post by:
I am using Access 2003. (I am also using ADO in the vast majority of my code. I recently read a post that indicated that ADO is not all that is was initially cracked up to be. In the back of my...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5643
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
435
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.