[AccessD] set control source for text box in VBA using Nz

Carolyn Johnson cjlabs at worldnet.att.net
Wed Nov 18 11:20:14 CST 2009


Access2003, WinXP

I have a report using a dynamic crosstab query.  I have set the control source for the text boxes based on the output field names of the crosstab query in the Report open property of the report.  I would like to have 0 printed instead of nothing if the value from the crosstab is null.


When I set the control source as 

        Me.Controls("txt" & rstData.Fields("Day") & "Product").ControlSource = Nz(Format(rstData.Fields("Date"), "ddd") & " " & rstData.Fields("ProductName"), 0)

in the Report open code, the Nz function is ignored.  The data are dsiplayed, but the null values are blank instead of 0.


If I set the control source in the property of the text box, the Nz function would work.


Is there a way to use the Nz function if the control source is set by code?



Thanks
Carolyn Johnson
St Louis, MO






More information about the AccessD mailing list