Dear All,
Thanks for a brilliant forum!
I have a function ReplaceX.
It is meant to find Chr(13) and substitute it with a ", " (comma space)
This worked until our suppliers now changed the way the address are formatted.
They now stipulate that there is a Space and a carriage return after each line of address.
So therefore a Chr(10) and Chr(13).
Below is my VB function to sort through the string and replace Chr(13).
So now instead of trying just to replace Chr(13) I have to find and replace Chr(13) and Chr(10) simultaneously with ", " within my function, so I can use it within my query -
I.e. SiteAddress: OneLineReplace([UNI7LIVE_DCAPPL].[ADDRESS])
Any help will be very, very much appreciated, I am desparate, I have tried quite a few ways, but none seem to work. I desparatly need this, as alot of my reports are letters/certificates sent out.
Thank you !!
Thank you,
Kind regards
Triacona
Thanks for a brilliant forum!
I have a function ReplaceX.
It is meant to find Chr(13) and substitute it with a ", " (comma space)
This worked until our suppliers now changed the way the address are formatted.
They now stipulate that there is a Space and a carriage return after each line of address.
So therefore a Chr(10) and Chr(13).
Below is my VB function to sort through the string and replace Chr(13).
Code:
[COLOR=#204A87]Option Compare Binary[/color]
[COLOR=#4E9A06]' Otherwise, the function will replace spaces with percent signs.[/color]
[COLOR=#204A87]Option Explicit[/color]
[COLOR=#4E9A06]'============================================================
'The following function will:
' - Find the tabs in a Text or Memo field.
' - Call another function to replace the tabs.
'============================================================[/color]
[COLOR=#204A87]Function[/color] FindTabs(WhichField [COLOR=#204A87]As String[/color]) [COLOR=#204A87]As String[/color]
[COLOR=#204A87]Dim[/color] x [COLOR=#204A87]As Integer[/color], strText [COLOR=#204A87]As String[/color]
[COLOR=#204A87]Dim[/color] start [COLOR=#204A87]As Integer[/color]
[indent]start = 1
x = 1
strText = WhichField[/indent]
[COLOR=#204A87]Do Until[/color] x = 0
[COLOR=#4E9A06]' Chr(13) is the carriage return character.
' Replace Chr(9) with the ANSI code for the character
' you are searching for.[/color]
[indent]x = InStr(start, strText, vbCrLf) [COLOR=#4E9A06]'vbCrLf replacing Chr(13), because now our database adds a space then return, not just a return[/color][/indent]
[indent]start = x + 1[/indent]
[COLOR=#204A87]If[/color] x > 0 [COLOR=#204A87]And Not[/color] IsNull(x) [COLOR=#204A87]Then[/color]
[indent]strText = ReplaceTabs(x, strText)[/indent]
[COLOR=#204A87]End If
Loop[/color]
[indent]FindTabs = strText[/indent]
[COLOR=#204A87]End Function[/color]
[COLOR=#4E9A06]'==================================================================
' The following function is called from the FindTabs() function. It
' accepts two arguments, strText and start. The function replaces
' tabs with %. It returns the updated text.
'==================================================================
[/color]
[COLOR=#204A87]Function[/color] ReplaceTabs(start [COLOR=#204A87]As Integer[/color], strText [COLOR=#204A87]As String[/color]) [COLOR=#204A87]As String[/color]
[COLOR=#4E9A06]' Replace % with the character you want to substitute.[/color]
[indent]Mid(strText, start, 1) = ", "
ReplaceTabs = strText[/indent][COLOR=#204A87]End Function[/color]
[COLOR=#204A87]Function[/color] OneLineReplace(strText As String) [COLOR=#204A87]As String[/color]
[COLOR=#4E9A06]'Replace % with the character you want to substitute.[/color]
[indent]OneLineReplace = Replace(strText, vbCrLf, ", ") [COLOR=#4E9A06]'vbCrLf replacing Chr(13), because now our database adds a space then return, not just a return[/color][/indent]
[COLOR=#204A87]End Function[/color]
So now instead of trying just to replace Chr(13) I have to find and replace Chr(13) and Chr(10) simultaneously with ", " within my function, so I can use it within my query -
I.e. SiteAddress: OneLineReplace([UNI7LIVE_DCAPPL].[ADDRESS])
Any help will be very, very much appreciated, I am desparate, I have tried quite a few ways, but none seem to work. I desparatly need this, as alot of my reports are letters/certificates sent out.
Thank you !!
Thank you,
Kind regards
Triacona