Multi-field Primary key and subform

sparkyrose

Registered User.
Local time
Today, 16:07
Joined
Sep 12, 2007
Messages
31
Hi all,

My Db has a master table with a two-field primary key.

I have a main form, based on a query that primarily grabs data from that table.

The form has a subform based on a table which is the "many" side of a one-to-many relationship with the master table. I'm having a problem adding individual records to the subform.

The subform is linked via Master/child fields to the main form, but only on one of the two fields comprising the PK. When I add a new record in the sub it does not pull the PK data to the FK fields in the sub table and I suspect it is because of only having one of them properly linked.

The subform relates to an annual certification process that we track with vendors. The sub-table is populated each year with the two FK values for all qualifying vendors in one go. If I then need to add a single certification record for a single vendor I want to have a button on the subform that will pull the values from the main form fields, and ask the user for the cert year.

I tried adding a new record in vba via

Code:
Private Sub btnAddSingleRec_Click()

Forms!frmMainForm!subfrmCurrentProcess.SetFocus

DoCmd.GoToRecord , , acNewRec
DoCmd.OpenQuery "qryAddSingleCert"

with the query being an Update query with the following in the Update To line and "Is Null" in criteria:

Forms!Mainform!PKField1
Forms!Mainform!PKField2
[Enter Cert Year]

This doesn't throw an error, but the Access warnings say I'm updating 0 Rows.

Any help gratefully appreciated!
 
This is a lot of verbiage to wrap one's head around - that's probably why you did not get much response.

Post a db stripped to the bare essentials required to illustrate the problem, and post instructions how to create the problem and what exactly the desired outcome should be.

Someone might be better able to help you.
 
Please show us a jpg of your tables and relationships - you may have to zip the file.
 
Sounds like the LinkMasterFields and LinkChildFields Properties of the subformcontrol only have one of the key fields listed.
 

Users who are viewing this thread

Back
Top Bottom