I am geting the error "You tried to assign the Null value to a variable that is not a Variant data type" after deleting the data from a field. I kinda get why I am getting the error, but I need to find a way to avoid the user getting it. Also, no code behind it is trying to assign any value to any variable. I'll explain further how I am getting it:
I have an orders form, which the structure is extremely similar to the orders table from the Northwind sample database. The form is based on a query of my Customers table and Orders table. When the user enters the customers account number in the account number field in the orders table, it "auto populates" the rest of the customer data from the customers table. If the user, for whatever reason, deletes the account number, and then tries to switch fields, they get the error indicated above. I can understand that the reason I am getting this is because that is the field that is "linking" the customers and orders table, and an empty value would essentially break that link and "confuse" the database.
So my question is, how can I supress that warning? The reason why a user may delete the contents of that filed, generating the error, would be only when entering new records/orders. The user often may start a new order form, and enter the account number to only realize that the customer is not yet set up in the database (account numbers are generated from another software system and then set up in this database only when need be). If that is the case the user may sometimes delete the entered account number before clicking my "cancel" button, which would throw that error.
What I would ultimatelly like the behavior to be is that if the user "clears" the contents of that field, it undo's any data entry since the form was opened. Obviously I have tried to use undo commands in the after update event of the field, but this error is triggered before the after update event is triggered.
Any suggestions on how to aviod this error?
I have an orders form, which the structure is extremely similar to the orders table from the Northwind sample database. The form is based on a query of my Customers table and Orders table. When the user enters the customers account number in the account number field in the orders table, it "auto populates" the rest of the customer data from the customers table. If the user, for whatever reason, deletes the account number, and then tries to switch fields, they get the error indicated above. I can understand that the reason I am getting this is because that is the field that is "linking" the customers and orders table, and an empty value would essentially break that link and "confuse" the database.
So my question is, how can I supress that warning? The reason why a user may delete the contents of that filed, generating the error, would be only when entering new records/orders. The user often may start a new order form, and enter the account number to only realize that the customer is not yet set up in the database (account numbers are generated from another software system and then set up in this database only when need be). If that is the case the user may sometimes delete the entered account number before clicking my "cancel" button, which would throw that error.
What I would ultimatelly like the behavior to be is that if the user "clears" the contents of that field, it undo's any data entry since the form was opened. Obviously I have tried to use undo commands in the after update event of the field, but this error is triggered before the after update event is triggered.
Any suggestions on how to aviod this error?