SOLVED -Copy SubForm Primary Key to another SubForms Foreign Key

5 replies [Last post]
mcMark
Offline
Last seen: 6 days 11 hours ago
Title: ★★
Joined: 15 May 2016
Posts: 16
**Okay, I’m finally asking for help…Help?

Designing a database for a Foodbank that computer illiterate people(volunteers) will/can correctly use.
Simplifying this has become involved. It has to generate the proper data for it to be useful.

Following basic rules of design I have 4 tables. 1 MainForm and 3 SubForms

MainForm – Client_info

  • ClientID
  • Name Fields, Gender, Birthdate

SubForm – Address

  • AddressID, ClientID
  • Address Fields, Including some list boxes to help keep the data consistent

SubForm – HouseHold

  • HouseHoldID, ClientID
  • 4 age groups fields

SubForm – DatesServed

  • ServingNumberID, ClientID, HouseHoldID
  • DateServed, ReturningClient CheckBox

I know how to copy a MainForm Primary Key to a SubForm Foreign Key.
Is there an easy, no Macro technique to copy a SubForm Primary Key to another SubForm Foreign Key?

Copy the HouseHold Primary Key, HouseHoldID, into the DatesServed Foreign Key, HouseHoldID

I have been trying to write a Macro for this but it has been a few years since I written any serious code.(4000+ lines)
And the information I have read, Access2Base & The Base Handbook, have helped some but both seem to be…not correct or consistent?

The HouseHoldID field must remain in the DatesServed Table. A Clients HouseHold data/numbers may change, in which case a new HouseHoldID for the Client will be generated.(Another Hurdle Approaching)
The old HouseHold ID is still needed data.
The DatesServed, DateServed date must reference the the correct HouseHoldID which contains the data/numbers at the time of the Clients visit.
*I think that is explained correctly? *

Any help and all solutions will be credited accordingly.
It is better to have and not need than to need and not have… …until you have too much and can’t find what you need
F3K Total
Offline
Last seen: 2 weeks 6 hours ago
Title: ★★★★★
Joined: 14 Oct 2013
Posts: 201
Copy SubForm Primary Key to another SubForms Foreign Key
Hi, no macro needed, find attached an example to investigate the forms structure by using the Form Navigator. R
AttachmentSize
Foodbank.png 13.32 KB
Foodbank.odb 16.14 KB
mcMark
Offline
Last seen: 6 days 11 hours ago
Title: ★★
Joined: 15 May 2016
Posts: 16
Copy SubForm Primary Key to another SubForms Foreign Key
I had tried the stepping down in SubForms before but was losing reference data.

Did it again to demonstrate the issue for a reply and it was working correctly. KEY WORD – was

Saved the form, closed it, saved the database, closed, reopen, loaded form and well…was. Let me finish what I was initially going to update to your reply.

It is better to have and not need than to need and not have… …until you have too much and can’t find what you need
mcMark
Offline
Last seen: 6 days 11 hours ago
Title: ★★
Joined: 15 May 2016
Posts: 16
Copy SubForm Primary Key to another SubForms Foreign Key
Some more on the structure and why. There are 2 user Forms. Client_Information_Form
  • Used for entering new Clients and current Clients that exist on several hundred index cards

  • The HouseHoldID in the DatesServed Table is not needed since this is only a reference for their last visit…one visit a month only

LookUp_Birthdate_Form

  • Eventually will be used most of the time after the index cards are all entered
  • Uses the Clients Birthdate and Gender to display a results table from which the Client is selected
  • This lists a History table and other Client information

When I Move the subform accordingly and update the Master Slave Properties I lose some of the data results but the HouseHoldID transfers over.

AttachmentSize
ClientInformationForm.jpg 195.18 KB
BirthdateLookUpForm.jpg 331.54 KB
BirthdateLookUpFormEdit.jpg 340.37 KB
It is better to have and not need than to need and not have… …until you have too much and can’t find what you need
mcMark
Offline
Last seen: 6 days 11 hours ago
Title: ★★
Joined: 15 May 2016
Posts: 16
Copy SubForm Primary Key to another SubForms Foreign Key
With some more testing, it works partially…maybe more than less. Although I do miss that initial DataServed data. The table allows for new entries and saves them.

I noticed some records missing in the table but not sure when those were deleted.

Thanks for the help. I may not had gone back to this otherwise for some time.

Now I just have to get the new HouseHold Record to occur,with a new HouseHoldID, when a change is made in the age fields.

UPDATE: Beer I found the cause for the missing data. The Hierarchy of the SubForms was the cause. That’s another issue resolved. Only 1, 2, 3…left. Tired

It is better to have and not need than to need and not have… …until you have too much and can’t find what you need
mcMark
Offline
Last seen: 6 days 11 hours ago
Title: ★★
Joined: 15 May 2016
Posts: 16
Solved
I suppose this is solved now. Big smile

But how do I turn off the grid lines/dots? Puzzled

It is better to have and not need than to need and not have… …until you have too much and can’t find what you need

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.