I have a pair of cascading combo boxes on an Access 2010 form, one (Source) unbound and one (InformationTitle) bound to a mandatory field in the form's underlying recordsource. Source is used to narrow down the choice available in InformationTitle.
The record source for the form is:
SELECT tblEvidence.EvidenceName, tblEvidence.EvidenceID, tblEvidence.InformationID FROM tblEvidence ORDER BY tblEvidence.EvidenceName;
The row source for Source (unbound combo) is:
SELECT tblSource.SourceID, tblSource.Source FROM tblSource ORDER BY tblSource.Source;
The row source for InformationTitle (bound to mandatory table field tblEvidence.InformationID)
SELECT tblInformation.InformationID, tblInformation.SourceID, tblInformation.Title
FROM tblInformation WHERE ([Source]) Is Null OR tblInformation.SourceID=[Source])
ORDER BY tblInformation.Title;
The relevant elements of the underlying tables are:
: EvidenceID (long); EvidenceName (text); InformationID (long)
: InformationID (long); Title (text)
: SourceID (long); Source (text)
All these fields are mandatory.
There is a many-to-one relationship between tblInformation and tblEvidence, and a many-to-one relationship between tblSource and tblInformation.
The validation rule on InformationID in tblEvidence is (Is Not Null).
The validation rule for InformationTitle on the form is Not IsNull (InformationTitle) -- although I don't think it should need one if the validation rule on the underlying table is working.
In Source_AfterUpdate, the following code executes:
Me.InformationTitle.Value = Null
In form_Current, the following code executes:
If IsNull(Me.InformationTitle) Then
Me.Source = 1 'The default value
Me.Source = Me.InformationTitle.Column(1)
There is no code in InformationTitle_AfterUpda
The cascade works as expected, with two exceptions.
1. If an existing record is edited, by (a) selecting a 'Source' which has no associated 'Information' records, and (b) saving the record without completing the InformationTitle field, the old value of InformationTitle is restored when the expected behaviour is that an error be reported and the user required to fix their data. (If a new record is created and saved with InformationTitle blank, the error is trapped as expected).
2. If an existing record is edited, by (a) changing the selection of 'Source', and (b) selecting an associated piece of 'Information' and (c) reverting to the original 'Source', 'InformationTitle' also reverts to its previous value when the expected behaviour is that it would be set to Null ready for the user to make a new selection.
What blindingly obvious mistake have I made? I've been struggling with this for two days, and haven't found anything that sets me on the right path.