Updating 'child' records based on 'parent' record (1 Viewer)

martinjward

Registered User.
Local time
Today, 15:32
Joined
Sep 28, 2007
Messages
22
I am creating an audit database where I have an Audit header record (parent) and multiple tests against the the header (child records) all linked to the audit header by a Primary Key, the Audit Number of the header.

I wish to be able to prevent editing the tests by setting a flag on each test, when the audit has been finalised. I am ok with the with all the bits od code that lead up to making the decision if the tests ned to be updated, but I do not know where to go from there

I know I have to..

Create a DAO record set of test records, get the first record and update the flag and the move to the next record until all have been processed - but I do not know where to start.

Can someone help me?:confused:
 

ajetrumpet

Banned
Local time
Today, 09:32
Joined
Jun 22, 2007
Messages
5,638
I wish to be able to prevent editing the tests by setting a flag on each test, when the audit has been finalised.
What do you mean by this?? Is this "flag" idea what you are referencing when you talk about writing code for the recordset??
 

martinjward

Registered User.
Local time
Today, 15:32
Joined
Sep 28, 2007
Messages
22
The flag is just a Yes / No field which will be refenced in the Current event of the form. If the flag is Tue then AllowEdits = False (i.e. lock record flag is true, do not allow edits).
 

ajetrumpet

Banned
Local time
Today, 09:32
Joined
Jun 22, 2007
Messages
5,638
Martin, you have said that...

1) You will have a "yes/no" field on your form that is related to your child "test" records.
2) The "yes/no" field will indicate weather the test (record) is locked.

What you have not said is...

** This is the criteria that must be satisfied in order for the "yes/no" box to be checked..."????"

Thus, without that statement, your problem cannot be fully solved, but I can tell you that;
** If the criteria for the '"yes/no" field to be checked' has been satified, the statement to satisfy this....
I wish to be able to prevent editing the tests by setting a flag on each test, when the audit has been finalised.
is this...
Code:
Private Sub_Current

  If Me.CheckBoxName = True Then
    Me.AllowEdits = False
  
  End If

End Sub
But what other code do you need before that statement....?? You will not know unless you can answer the question: "What determines weather the box can be checked?? What determines weather the audit is finalized??"
 

martinjward

Registered User.
Local time
Today, 15:32
Joined
Sep 28, 2007
Messages
22
I am OK with that bit - what I am strugling with is updating the flag on the child records, based on the status of the parent record.

To clarify,,

If update the status of the parenet to record to (for example) complete, I wish to set the flag on the children to True (so not allow edits) so they can not be changed.

I do not know where to start with the following...

Obtaining a collection of all of the child records, using a reference number on the parent as my primary key, looping through the child records, updaing my flag field within the child records.
 

ajetrumpet

Banned
Local time
Today, 09:32
Joined
Jun 22, 2007
Messages
5,638
I do not know where to start with the following...

Obtaining a collection of all of the child records, using a reference number on the parent as my primary key
Why do you have to "obtain" the records?? This is probably not necessary. I assume you say this because you think that you actually need to SEE the records or take a "PHYSICAL" or "TANGIBLE" approach to update them...??? If this is the assumption; No, you don't need to do it this way.
looping through the child records, updaing my flag field within the child records.
Why are you needing to loop through them?? There is no need to write a loop in Basic if all you need to do is update child records based on ANY criteria of the parent record.
 

Users who are viewing this thread

Top Bottom