Good morning,
I did some changes and testing and found out something interesting. I added the required fields to the query so I can create a new record now.
Unfortunately the code does still throw the same error when I try to update the two combo boxes on existing entries. What surprised me was, that the audit code worked for the new entry, the OldValue was simply written to tblAuditTrail as NULL.
After that I did some more testing and this is were I simply do not understand things anymore . I created a second, identical form and did some changes on the code. I deleted the loop that goes through all the controls and set the controll to active control.
After that I called the Sub using the Before_Update event of the controls I want to audit.
This is were things get strange: The two combo boxes now work and the correct values are written to tblAuditTrail. Now if I try to update the text boxes below next it throws the same error as the combo boxes before. And to make the mess perfect: If I edit the textboxes first and the combo boxes second everything works without problems.....
I attached the updated version of the example database with both versions so you can see the changes and test it out yourself.
BTW: English is not my native language, I hope you can understand my explanation of the Problem.
I did some changes and testing and found out something interesting. I added the required fields to the query so I can create a new record now.
Unfortunately the code does still throw the same error when I try to update the two combo boxes on existing entries. What surprised me was, that the audit code worked for the new entry, the OldValue was simply written to tblAuditTrail as NULL.
After that I did some more testing and this is were I simply do not understand things anymore . I created a second, identical form and did some changes on the code. I deleted the loop that goes through all the controls and set the controll to active control.
Code:
Set ctl = Screen.ActiveControl
This is were things get strange: The two combo boxes now work and the correct values are written to tblAuditTrail. Now if I try to update the text boxes below next it throws the same error as the combo boxes before. And to make the mess perfect: If I edit the textboxes first and the combo boxes second everything works without problems.....
I attached the updated version of the example database with both versions so you can see the changes and test it out yourself.
BTW: English is not my native language, I hope you can understand my explanation of the Problem.