VBA change characters. Use Replace or Instr

B

bobdydd

Hi

I have a field called txtTransactionNumber which currenty has
16 numbers in it.
I am trying to find a way to replace the first 12 numbers with an asterisk *
and just leave the last 4 showing normally.

so that 1234 5678 9123 4567
will become **** **** **** 4567

I am trying the following

Private Sub Form_Current()
Me.txtTransactionNumber = Replace([txtTransactionNumber], , )
End Sub

But I'm not sure where to go from there

Can anyone help
Best Regards
 
J

John W. Vinson

Hi

I have a field called txtTransactionNumber which currenty has
16 numbers in it.
I am trying to find a way to replace the first 12 numbers with an asterisk *
and just leave the last 4 showing normally.

so that 1234 5678 9123 4567
will become **** **** **** 4567

I am trying the following

Private Sub Form_Current()
Me.txtTransactionNumber = Replace([txtTransactionNumber], , )
End Sub

But I'm not sure where to go from there

Can anyone help
Best Regards

Replace() won't work with this. It replaces some specified text with other
specified text, and you don't have the former!

Try instead:

"**** **** **** " & Right([txtTransactionNumber, 4)
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.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