S
SusanV
I have data that is full of CRLF and space characters (\x0D and x\0A) that
have to be removed in a temporary holding table called TempNarr (the
original data can't be altered). I've got the Replace function working
perfectly in a button's onClick event, but can't figure what to do next to
use the modified String in an UPDATE statement for the TempNarr table. Users
don't need to see the data refreshed in the form (although that would be
nice) as there's a report already setup to use the TempNarr table as it's
source. Below is the code I have so far, any help or even a link would be
fabulous!
TIA,
Susan
Private Sub FixNarr_Click()
DoCmd.SetWarnings True
DoCmd.RunSQL "Delete from TempNarr"
DoCmd.RunSQL "INSERT INTO TempNarr(MCODE, MCODETITLE," & _
"ESTHRS, PMCODE, NARR, MCAUSECODE) SELECT MCODE.MCODE," & _
"mcode.MCODETITLE, mcode.ESTHRS, mcode.PMCODE, mcode.NARR," & _
" mcode.MCAUSECODE FROM MCode" & _
" WHERE MCODE = Forms!frmFindMCode.MCode"
Dim strOld As String
Dim strFind As String
Dim strReplace As String
Dim strNew As String
Dim strOld1 As String
Dim strFind1 As String
Dim strReplace1 As String
Dim strNew1 As String
strFind = "\x0D"
strReplace = " " & Chr(13) & Chr(10)
strOld = Forms!frmFindMCode.NARR
MsgBox ("Narr: " & strOld)
strNew = Replace(strOld, strFind, strReplace)
strFind1 = "\x0A"
strReplace1 = ""
strOld1 = strNew
strNew1 = Replace(strOld1, strFind1, strReplace1)
MsgBox ("Now Narr: " & strNew1)
End Sub
have to be removed in a temporary holding table called TempNarr (the
original data can't be altered). I've got the Replace function working
perfectly in a button's onClick event, but can't figure what to do next to
use the modified String in an UPDATE statement for the TempNarr table. Users
don't need to see the data refreshed in the form (although that would be
nice) as there's a report already setup to use the TempNarr table as it's
source. Below is the code I have so far, any help or even a link would be
fabulous!
TIA,
Susan
Private Sub FixNarr_Click()
DoCmd.SetWarnings True
DoCmd.RunSQL "Delete from TempNarr"
DoCmd.RunSQL "INSERT INTO TempNarr(MCODE, MCODETITLE," & _
"ESTHRS, PMCODE, NARR, MCAUSECODE) SELECT MCODE.MCODE," & _
"mcode.MCODETITLE, mcode.ESTHRS, mcode.PMCODE, mcode.NARR," & _
" mcode.MCAUSECODE FROM MCode" & _
" WHERE MCODE = Forms!frmFindMCode.MCode"
Dim strOld As String
Dim strFind As String
Dim strReplace As String
Dim strNew As String
Dim strOld1 As String
Dim strFind1 As String
Dim strReplace1 As String
Dim strNew1 As String
strFind = "\x0D"
strReplace = " " & Chr(13) & Chr(10)
strOld = Forms!frmFindMCode.NARR
MsgBox ("Narr: " & strOld)
strNew = Replace(strOld, strFind, strReplace)
strFind1 = "\x0A"
strReplace1 = ""
strOld1 = strNew
strNew1 = Replace(strOld1, strFind1, strReplace1)
MsgBox ("Now Narr: " & strNew1)
End Sub