Count Commas and Replace

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

I have a Text feild and I want it to have a comma on the end, However there
are commas within the string already and the user may have entered a comma
already to the end.

How would I determine if there is no comma on the end and if not to add the
comma?

Thanks
Matt
 
D

Douglas J Steele

If Right(Nz(Me.MyTextField, ""), 1) <> "," Then Me.MyTextField =
Me.MyTextField & ","
 
D

Douglas J Steele

IIf(Right(Nz([MyTextField], ""), 1) <> ",", [MyTextField] & ",",
[MyTextField])


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


mattc66 via AccessMonster.com said:
How would i use that in a query? I tried the IIF, but it fails.

Matt
I have a Text feild and I want it to have a comma on the end, However there
are commas within the string already and the user may have entered a
comma
[quoted text clipped - 5 lines]
Thanks
Matt

--
Matt Campbell
mattc (at) saunatec [dot] com

Message posted via AccessMonster.com
 
D

Douglas J. Steele

To remove all commas?

Replace([MyTextField], ",", "")

To remove a comma at the end of the string?

IIf(Right(Nz([MyTextField, ""), 1) = ",", Left([MyTextField],
Len([MyTextField])-1), [MyTextField])

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


mattc66 via AccessMonster.com said:
How would I write the statement to remove the comma if it finds one?
How would i use that in a query? I tried the IIF, but it fails.
[quoted text clipped - 8 lines]
Thanks
Matt

--
Matt Campbell
mattc (at) saunatec [dot] com

Message posted via AccessMonster.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top