Using the Replace function (1 Viewer)

aziz rasul

Active member
Local time
Today, 10:47
Joined
Jun 26, 2000
Messages
1,935
I have a field where I want to replace specific values to a different value as part of an Encryption process. I then want to Decrypt the data back to what it was.

Hence if I have say the following data which forms a part number of a product

yEr456

I want to Encrypt this so that I end up with

sGb!()

I am using the following code to do this. If I use the code to replace the y to s, I use

Code:
Current.Execute "UPDATE tblTempEncryption INNER JOIN [" & strTableName & "] ON tblTempEncryption.[DATAAUTONUMBER - " & strFieldName & "] = [" & strTableName & "].[DATAAUTONUMBER - " & strFieldName & "] SET [" & strTableName & "].[" & strFieldName & "] = Replace([" & strTableName & "]![" & strFieldName & "],'y','s');"

However when the following code is run afterwards to replace any 'S' to 'C', it replaces the 's' to 'C'.

Code:
Current.Execute "UPDATE tblTempEncryption INNER JOIN [" & strTableName & "] ON tblTempEncryption.[DATAAUTONUMBER - " & strFieldName & "] = [" & strTableName & "].[DATAAUTONUMBER - " & strFieldName & "] SET [" & strTableName & "].[" & strFieldName & "] = Replace([" & strTableName & "]![" & strFieldName & "],'S','C');"

In other words my code doesn't distinguish between 's' and 'S'. Hence I end up with 'y' becoming a 'C' rather an a 's'.
 

aziz rasul

Active member
Local time
Today, 10:47
Joined
Jun 26, 2000
Messages
1,935
Many thanks
 

Users who are viewing this thread

Top Bottom