Hi all,
I have code on the on exit of a textbox called Name_input, which takes the inputted name getting rid of any middle characters or strings to leave first string and last string which is copied to another textbox called SAL input (short for salutation).
e.g.
Mr M D Donald
will result
Mr Donald
The problem i get is if the user decides to enter (in name_input) one string or one character for instance "occupier" i get an error if the SAL_INPUT textbox has no value in it (null). Another problem with the code is if there is an entry already in the SAL_INPUT textbox it will not overide it with the changes which i want it to do.
This is the code
Also myinstrReverse is a module as access does not support it:
p.s. i don't want the SAL_input to be bound to the Name_input textbox but to leave it unbound.
Any help appreciated, thanks in advance,
M-.
I have code on the on exit of a textbox called Name_input, which takes the inputted name getting rid of any middle characters or strings to leave first string and last string which is copied to another textbox called SAL input (short for salutation).
e.g.
Mr M D Donald
will result
Mr Donald
The problem i get is if the user decides to enter (in name_input) one string or one character for instance "occupier" i get an error if the SAL_INPUT textbox has no value in it (null). Another problem with the code is if there is an entry already in the SAL_INPUT textbox it will not overide it with the changes which i want it to do.
This is the code
Code:
Private Sub Name_input_Exit(Cancel As Integer)
If Trim(Me!SAL_input) & "" = "" Then
If Not IsNull([Name_input]) Then
Me!SAL_input = Left([Name_input], _
InStr(1, [Name_input], " ") - 1) & " " & _
Right([Name_input], Len([Name_input]) - _
MyInStrReverse([Name_input], " "))
End If
End If
End Sub
Also myinstrReverse is a module as access does not support it:
Code:
Function MyInStrReverse(Instring As String, Searchstring As String)
Dim i As Integer
Dim Char As String
i = Len(Trim(Instring))
Do While Char <> Searchstring
Char = Mid(Trim(Instring), i, 1)
i = i - 1
Loop
MyInStrReverse = i + 1
End Function
p.s. i don't want the SAL_input to be bound to the Name_input textbox but to leave it unbound.
Any help appreciated, thanks in advance,
M-.