A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Help with Pop Up Form



 
 
Thread Tools Display Modes
  #1  
Old May 31st, 2004, 10:18 AM
Sandra
external usenet poster
 
Posts: n/a
Default Help with Pop Up Form

I have a db of donors where I have a tabbed form
consisting of 3 main tables:
Page 1 - Master record of the donor for address, etc.
Page 2 - Subform of Individual records related to master
record
Page 3 - Subform of Donations related to each individual
record

On the Donations form I have a list box for donation
types. If "In-Kind" is selected I have a pop-up form for
a table to contain a detailed description of the donated
items.

The In-Kind form pops up as expected but it does not
acquire the link from the PK in the Donations record, and
upon exit I get the error message:
'You cannot add or change a record because a related
record is required in table "Donations" '.
In relationships I have a one-to-one between Donations
and InKind tables with referential integrity so I presume
the relationship is OK. The list box is selected after
the Donation record has acquired it's unique PK and
several other fields have been filled in.

What am I missing here?

Thanks for any advice,
Sandra


  #2  
Old May 31st, 2004, 01:38 PM
Rick Brandt
external usenet poster
 
Posts: n/a
Default Help with Pop Up Form

"Sandra" wrote in message
...
I have a db of donors where I have a tabbed form
consisting of 3 main tables:
Page 1 - Master record of the donor for address, etc.
Page 2 - Subform of Individual records related to master
record
Page 3 - Subform of Donations related to each individual
record

On the Donations form I have a list box for donation
types. If "In-Kind" is selected I have a pop-up form for
a table to contain a detailed description of the donated
items.

The In-Kind form pops up as expected but it does not
acquire the link from the PK in the Donations record, and
upon exit I get the error message:
'You cannot add or change a record because a related
record is required in table "Donations" '.
In relationships I have a one-to-one between Donations
and InKind tables with referential integrity so I presume
the relationship is OK. The list box is selected after
the Donation record has acquired it's unique PK and
several other fields have been filled in.

What am I missing here?


The only way Access *automatically* propagates a foreign key value to a child
record is by using an embedded subform within a parent form. If you are opening
a separate form as a popup then there is no mechanism to automatically link that
record to the parent record you opened the popup from. As far as Access is
concerned you are simply opening a separate form bound to a separate table and
then creating a record. The fact that you opened the popup from another form is
irrelevant as is the fact that the table for the popup has a relationship
defined to the table the calling form is bound to.

You, as the developer must either design the calling form to "push" the foreign
key value to the popup when opening it or design the popup form so it "pulls"
the foreign key value from the calling form.

Example of a "push":

DoCmd.OpenForm "MyPopUp"
Forms!MyPopUp!FKField = Me.ID

For a "pull", you can use code in the popup form's open event to retrieve values
from the calling form or you can set the default value for the foreign key field
so that it comes from the calling form. The latter assumes that the popup is
never used in circumstances where the parent form is not open.


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com





  #3  
Old May 31st, 2004, 01:55 PM
Rick Brandt
external usenet poster
 
Posts: n/a
Default Help with Pop Up Form ADDITION

"Rick Brandt" wrote in message
...

The only way Access *automatically* propagates a foreign key value to a child
record is by using an embedded subform within a parent form. If you are

opening
a separate form as a popup then there is no mechanism to automatically link

that
record to the parent record you opened the popup from. As far as Access is
concerned you are simply opening a separate form bound to a separate table and
then creating a record. The fact that you opened the popup from another form

is
irrelevant as is the fact that the table for the popup has a relationship
defined to the table the calling form is bound to.

You, as the developer must either design the calling form to "push" the

foreign
key value to the popup when opening it or design the popup form so it "pulls"
the foreign key value from the calling form.

Example of a "push":

DoCmd.OpenForm "MyPopUp"
Forms!MyPopUp!FKField = Me.ID

For a "pull", you can use code in the popup form's open event to retrieve

values
from the calling form or you can set the default value for the foreign key

field
so that it comes from the calling form. The latter assumes that the popup is
never used in circumstances where the parent form is not open.


Looking again at the error you were getting I think the actual issue is that you
need to save the record on the calling form before opening the popup. I
recommend...

Me.Dirty = False
DoCmd.OpenForm...


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:12 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.