Simon said:
in access i type in a post code like SA258LP What code can i run that
will auto correct it to SA25 8LP
I need a Space 3 characters before the end
Try the following code in the AfterUpdate event of your textbox or in an
Update query:
Public Function AddChars(strIn As String, strChar As String, intPlaces As
Integer) As Variant
On Error Resume Next
AddChars = Left(strIn, Len(strIn) - intPlaces) & strChar & Right(strIn,
intPlaces)
End Function
Save the above in a Standard Module, and call it like:
Private Sub Post_Code_AfterUpdate ()
AddChars([Post Code], " ", 3)
End Sub
The query:
UPDATE tblMyData SET tblMyData.[Post Code] = AddChars([Post Code]," ",3);