D
Deleted member 147267
Guest
We often ask Original Poster to upload a copy of their db but the issue might be that it contains sensitive data. Complete data removal may not allow us to troubleshoot the OP's issue because queries, forms, etc. need records in order to observe or trouble shoot the problem.
Here's a little function that we could point them to whereby they could, ON A COPY OF THEIR DB, randomize string field data by using an update query that calls the function below. This could solve the issue of revealing sensitive data by randomizing all or part of a string field. The function call goes into the UPDATE TO row of the query design grid and a sample sql statement would look like
The supposition is that it may be desirable to retain n characters at the beginning of the string and randomize the rest, hence the numeric parameter. If not, use 0 (untested). The function call would go into each text field that you want to randomize, using the proper field reference of course. The function being called is:
***NOTE***
Randomizing data is only practical IF the values are NOT PK (Primary Key) values, or if they are and exist as meaningful data, then Cascade Updates should be set in relationships between a field to be randomized and any other table where those values exist as Foreign Keys. Randomizing one side of a relationship and not the other would be pointless.
Lastly I'd mention that the user should realize that the result of the function cannot be reverse engineered; i.e. once randomized there is no way to determine what the original values were.
Here's a little function that we could point them to whereby they could, ON A COPY OF THEIR DB, randomize string field data by using an update query that calls the function below. This could solve the issue of revealing sensitive data by randomizing all or part of a string field. The function call goes into the UPDATE TO row of the query design grid and a sample sql statement would look like
Code:
UPDATE tbl1 SET tbl1.field1 = randomizedata(tbl1.field1,3);
Code:
Function RandomizeData(strField As String, i As Integer) As String
Dim str1 As String, str2 As String
'i= count of characters from beginning of string that are to be retained.
'Pass to Left function and assign to str1
str1 = Left(strField, i)
'make loop counter start at position number of NEXT character which is to be replaced.
'End value is string length.
For i = i + 1 To Len(strField)
'make str2 equal current value + a random lower case character from a to z
'and repeat to end of counter. Spaces are retained.
If Mid(strField, i, 1) = " " Then
str2 = str2 + Mid(strField, i, 1)
Else
str2 = str2 & Chr((121 - 97 + 1) * Rnd + 97)
'Debug.Print str2
End If
Next
'piece left and right parts together and return to query
RandomizeData = str1 + str2
'e.g if input value is 'Donald Duck', output string with 1st 2 characters retained might be Dosnoh itat
End Function
Randomizing data is only practical IF the values are NOT PK (Primary Key) values, or if they are and exist as meaningful data, then Cascade Updates should be set in relationships between a field to be randomized and any other table where those values exist as Foreign Keys. Randomizing one side of a relationship and not the other would be pointless.
Lastly I'd mention that the user should realize that the result of the function cannot be reverse engineered; i.e. once randomized there is no way to determine what the original values were.