VBA change characters. Use Replace or Instr

  • Thread starter Thread starter bobdydd
  • Start date Start date
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
 
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
 
Back
Top