vba - Display zero if null -


i have vba code on form performs of total number of errors query.

private sub cboprojectid_change()     dim vartotalerrors variant     vartotalerrors = dlookup("[total errors]", "[project_total_errors_query]", "[project_id] = " & varcombokey)     me.txttotalerrors = vartotalerrors  end sub 

what condition need add vba code automatically populate value of 0 when total_errors null?

you can feed dlookup value nz , assign result text box directly, simplifies code.

private sub cboprojectid_change()     me.txttotalerrors = nz(dlookup("[total errors]", _         "[project_total_errors_query]", _         "[project_id] = " & varcombokey), 0) end sub 

Comments