HalloweenWeed
Member
- Local time
- Today, 06:25
- Joined
- Apr 8, 2020
- Messages
- 220
Thank you for your time @Pat Hartman , that means no I can't use the before update event for my purpose.
Perhaps I should rephrase. I have the following form:
and it is a "single form" with record selectors, you can either edit or add transactions. However, there are rules about what is acceptable in each field depending on the setting in other fields. These rules are too complicated to put into control validations, and even if I did that would severely limit the order that the items could be entered (entry would become a tedious process with error messages popping up). For instance, for cash-only type transactions (deposits/withdrawals) the shares must be 0 and there should not be a "security account" entry (I guess that could be ignored with that transaction type when doing the account and statistic calculations later). For dividends, the shares must be 0. For all transaction types that are not splits the numerator and denominator must be 1.
One could put the transaction type in the validation of the other controls, but this doesn't undo the settings of the other controls when a different transaction type is selected.
I don't want to need to delete the "oops" records because of shoddy validation, and it seems Access saves a new record on the first field change. I don't want the record there at all if it was not valid. How do I go about this?
I am going to try the Workspace (.CommitTrans and .Rollback) method in vba, but when do I fire my vba validation rules? If it's on close, that won't work because the user can edit a number of records before closure, that would be rude to undo all of them. The user could also edit existing records before trying to add one, in which case I would need to do .CommitTrans before the user begins making an added record, what event do I use for that? Or am I making this too complicated, is there an easier way??? I could create different forms for edit & add record...
I have never used the Workspace (.CommitTrans and .Rollback) methods before, although I have studied what I think would be the syntax.
Perhaps I should rephrase. I have the following form:
and it is a "single form" with record selectors, you can either edit or add transactions. However, there are rules about what is acceptable in each field depending on the setting in other fields. These rules are too complicated to put into control validations, and even if I did that would severely limit the order that the items could be entered (entry would become a tedious process with error messages popping up). For instance, for cash-only type transactions (deposits/withdrawals) the shares must be 0 and there should not be a "security account" entry (I guess that could be ignored with that transaction type when doing the account and statistic calculations later). For dividends, the shares must be 0. For all transaction types that are not splits the numerator and denominator must be 1.
One could put the transaction type in the validation of the other controls, but this doesn't undo the settings of the other controls when a different transaction type is selected.
I don't want to need to delete the "oops" records because of shoddy validation, and it seems Access saves a new record on the first field change. I don't want the record there at all if it was not valid. How do I go about this?
I am going to try the Workspace (.CommitTrans and .Rollback) method in vba, but when do I fire my vba validation rules? If it's on close, that won't work because the user can edit a number of records before closure, that would be rude to undo all of them. The user could also edit existing records before trying to add one, in which case I would need to do .CommitTrans before the user begins making an added record, what event do I use for that? Or am I making this too complicated, is there an easier way??? I could create different forms for edit & add record...
I have never used the Workspace (.CommitTrans and .Rollback) methods before, although I have studied what I think would be the syntax.