I want to call up a form and have the user enter an address and then go through the below module to remove all characters not wanted. The module works fine in degug test. I just can't figure out how I can link this function to my form. I set the properties of an address data item to afterupdate openmodule below. I am not sure if my address is being passed through the module. The afterupdate brings me to the module code and then stops there. It does not bring me back to my form and replace the address data item eliminating the stripstring characters.
Do I need to substitute the mystr word with my data item name? Any clue what I need to do?
Option Explicit
'Function StripString()
'Returns a string minus a set of specified chars.
Function StripString(mystr As Variant) As Variant
On Error GoTo StripStringError
Dim strchar As String, strholdString As String
Dim I As Integer
'exit if the passed value is null.
If IsNull(mystr) Then Exit Function
'exit if the passed value is not a string.
If VarType(mystr) <> 8 Then Exit Function
'check each value for invalid characters.
For I = 1 To Len(mystr)
strchar = Mid$(mystr, I, 1)
Select Case strchar
Case ".", ",", "-", "#"
'Do nothing
Case Else
strholdString = strholdString & strchar
End Select
Next I
' Pass back corrected string
StripString = strholdString
StripStringEnd:
Exit Function
StripStringError:
MsgBox Error$
Resume StripStringEnd
End Function
Do I need to substitute the mystr word with my data item name? Any clue what I need to do?
Option Explicit
'Function StripString()
'Returns a string minus a set of specified chars.
Function StripString(mystr As Variant) As Variant
On Error GoTo StripStringError
Dim strchar As String, strholdString As String
Dim I As Integer
'exit if the passed value is null.
If IsNull(mystr) Then Exit Function
'exit if the passed value is not a string.
If VarType(mystr) <> 8 Then Exit Function
'check each value for invalid characters.
For I = 1 To Len(mystr)
strchar = Mid$(mystr, I, 1)
Select Case strchar
Case ".", ",", "-", "#"
'Do nothing
Case Else
strholdString = strholdString & strchar
End Select
Next I
' Pass back corrected string
StripString = strholdString
StripStringEnd:
Exit Function
StripStringError:
MsgBox Error$
Resume StripStringEnd
End Function