Check if a field is empty

Gr3g0ry

Registered User.
Local time
Yesterday, 23:46
Joined
Oct 12, 2017
Messages
163
quantity = me.amount.value
keeps giving me an errow when amount is empty. is there a way to check if the field is empty and return 0 instead ?
 
If you want to automatically return a zero, use the Nz() function.

quantity = Nz(Me.Amount,0)
 
First, just to save you future typing, you can drop the .Value reference because for anything that HAS a value, the .Value property is the default.

Second, what is the data type of the "amount" field?
 
First, just to save you future typing, you can drop the .Value reference because for anything that HAS a value, the .Value property is the default.

Second, what is the data type of the "amount" field?
Double ... i have another thats Integer too ... might wanna use the same technique elsewhere
 
If no JOIN is involved in the formation of that RecordSource, numeric fields can't be null. They can be zero. If the control in question is bound to a non-JOIN recordset, it can't be null either, unless somehow NO record is selected - in which case EVERY bound field would be null.

Null occurs in JOINs when a matching record is not found in the JOIN query, and for unbound controls, you can get a null if something doesn't load the control (and it doesn't have an explicit default value). But the important part is that nobody has asked the question yet, so I guess I will.

You say that you get an error when the amount is empty. What, specifically, is the error message?
 
If no JOIN is involved in the formation of that RecordSource, numeric fields can't be null. They can be zero. If the control in question is bound to a non-JOIN recordset, it can't be null either, unless somehow NO record is selected - in which case EVERY bound field would be null.

Null occurs in JOINs when a matching record is not found in the JOIN query, and for unbound controls, you can get a null if something doesn't load the control (and it doesn't have an explicit default value). But the important part is that nobody has asked the question yet, so I guess I will.

You say that you get an error when the amount is empty. What, specifically, is the error message?
i had discontinued that effort. i had simply resorted to change the layout of my form. the suggestion made by @Pat Hartman had helped. tyvm kind sir
 

Users who are viewing this thread

Back
Top Bottom