简体   繁体   中英

MS Access data validation between form and subform

I have an MS Access database which tracks invoices. In the form I use to enter the data, I have the control [Amount] for the invoice amount (eg $100). In that form there is also a subform which tracks parts of the invoice (eg food supplies for $50 and cleaning supplies for $50). The main form also has the control [Breakdown Total] which sums up the breakdown amounts in the subform.

I am trying to make it so that, unless [Amount] = [Breakdown Total], you can't change records within the form. Because of the two-table structure, it seems that a data validation rule isn't working quite the way I want because it really only works when you fill in the [Amount] control and not if you then change the breakdown.

I thought of building an event to handle this, but I don't know what event to use--BeforeUpdate doesn't let me leave the control which doesn't match, which isn't helpful--what if that's the correct one?--and AfterUpdate doesn't seem to let me require that the suspicious record remain on the screen. Could someone please recommend the event I should be using?

Here was a solution i implemented at a client, recently. Not sure if it is exactly what you need but implements two ListBoxes, one to select the Top-Category and the other is Column'ed to display a Cross-Tab display of the Top-Category's children.

在此处输入图片说明

The Left Listbox is programmatically, in VBA, loaded information from an Access View and then the main-body Listbox is bound by a Cross-Tab creation algorithm. Now yours does not necessarily have to be as intracate or detailed as mine required. But you can get this done without a subform.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM