Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Forms _ Comma Coming Thru When Nz

Posted by: damian.green Feb 20 2020, 01:13 PM

How would you change the below code to not show the commas if any of the below fields?

CODE
Location = Nz(Me.Location, "") & (", " + Nz(Me.Address, "")) & (", " + Nz(Me.City, "")) & (", " + Nz(Me.State, "")) & (", " + Nz(Me.ZIPCode, ""))

Posted by: cheekybuddha Feb 20 2020, 01:40 PM

Search UA for 'The law of propagating Nulls'.

Try:

CODE
Location = Me.Location & vbNullString & (", " + Me.Address) & (", " + Me.City) & (", " + Me.State) & (", " + Me.ZIPCode)


hth,

d

Posted by: damian.green Feb 20 2020, 01:46 PM

Perfect. Thanks.

Posted by: cheekybuddha Feb 20 2020, 01:49 PM

Beware, you might get an initial comma if it's possible to have Me.Location = Null and a value in any of the other controls.

If so, the solution is a bit more complex.

thumbup.gif