I ran with this idea that I grabbed off this board and now I ran into a dead end...
I wanted to track the history of 2 specific fields on a subform. I saw an example that used an append query to do this. I created an append query that actually appends the entire record into a history table.
The fields in the append query look like this:
Field: Expr1: Forms!sbfPartsInventory_PS!SerialNumber
Append To: SerialNumber
Field:Expr2: Forms!sbfPartsInventory_PS!Date
Append To: TransactionDate
and so on....Expr3 is Status... Expr4 is PartInvID...Expr5 is the PONumber.
On the subform, in the OnChange event of the Date field of the subform
I added code to run the append query. (The user will change the date first and then change part status which is the next field on the subform).
DoCmd.SetWarnings False
DoCmd.OpenQuery "appAppendHistory_PartStatus"
DoCmd.SetWarnings True
Issue #1
When testing this by opening the subform itself....
The append query enters 8-9 entries in the history table. I'm only expecting 1 record to be appended. Not every field is changing. I can't figure out why it's appending that many records at a time. All entries are essentially duplicates except for the date_changed field which is defaulted to now(). Is OnChange the wrong event to use? Or is the append query the wrong approach for this?
Issue #2
When I test this from the parent form, when I try to change the date field I get the "Enter Parameter Value" dialog for each entry in the append query. Do I have to tell the parent form how to reference the subform
in the append query or something? by altering this statement in the subform? Forms!sbfPartsInventory_PS!Date
Any ideas would help!
Thanks!
I wanted to track the history of 2 specific fields on a subform. I saw an example that used an append query to do this. I created an append query that actually appends the entire record into a history table.
The fields in the append query look like this:
Field: Expr1: Forms!sbfPartsInventory_PS!SerialNumber
Append To: SerialNumber
Field:Expr2: Forms!sbfPartsInventory_PS!Date
Append To: TransactionDate
and so on....Expr3 is Status... Expr4 is PartInvID...Expr5 is the PONumber.
On the subform, in the OnChange event of the Date field of the subform
I added code to run the append query. (The user will change the date first and then change part status which is the next field on the subform).
DoCmd.SetWarnings False
DoCmd.OpenQuery "appAppendHistory_PartStatus"
DoCmd.SetWarnings True
Issue #1
When testing this by opening the subform itself....
The append query enters 8-9 entries in the history table. I'm only expecting 1 record to be appended. Not every field is changing. I can't figure out why it's appending that many records at a time. All entries are essentially duplicates except for the date_changed field which is defaulted to now(). Is OnChange the wrong event to use? Or is the append query the wrong approach for this?
Issue #2
When I test this from the parent form, when I try to change the date field I get the "Enter Parameter Value" dialog for each entry in the append query. Do I have to tell the parent form how to reference the subform
in the append query or something? by altering this statement in the subform? Forms!sbfPartsInventory_PS!Date
Any ideas would help!
Thanks!