Searching A String And Replacing A Code With A Serial Number
Having a real Bear of a time figuring this one out.
I have a database field that I am using the replace function to identify codes such as "SN#" and would like to replace them with an automatically incrementing Serial Number.
I have a Serialized Text box with a shared name of Serial that I am using as the source of the incrementing serial number.
When I use the replace function it is never incrementing the serial number that is used to replace the SN# code. It prints the same serial number across all 3 labels
Here is the vbscript I am using the detect the SN# code and replace it with the Value of the shared name Serial
Value=(ReplaceTest("SN#", Format.NamedSubStrings("Serial").Value))
Here is the function I am using that was copied verbatim from the Vbscript help
Function ReplaceTest(patrn, replStr)
Dim regEx, str1 ' Create variables.
str1 = Value
Set regEx = New RegExp ' Create regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Make case insensitive.
ReplaceTest = regEx.Replace(Value, replStr) ' Make replacement.
End Function
I have this code running on AutoselectedEvent but I have tried moving the code to the other Events with no success.
Anyone have any ideas on strategies for me to address this? I have tried setting this up with a Database field as the data source and then trying to modify the string with a vbscript transform. In the example above I am using a vbscript as the data source.
-
You'll want to do this on the 'OnSerialize' event to ensure that it occurs after every serialized number. And the appropriate script for this would be: Value = Replace(Field("databasefield") , "SN#", Format.NamedSubStrings("Serial").Value) 0
Please sign in to leave a comment.
Comments
1 comment