Article ID: 173975
Article Last Modified on 1/20/2007
MSACCESS caused an invalid page fault in MSACCESS.EXE.
An application error has occurred and an application error log is being generated. MSACCESS.exe
Option Explicit
Function ReplaceString(strSearch As String, strSearchFor As String, _
strReplaceWith As String)
On Error GoTo err_ReplaceString
' Searches the strSearch variable for strSearchFor
' and replaces it with strReplaceWith.
Dim lngFoundLoc As Long ' Location of match.
Dim lngLenRemove As Long ' Length of string being replaced.
' Set length of original text to skip.
lngLenRemove = Len(strSearchFor)
' Set location of match.
lngFoundLoc = InStr(1, strSearch, strSearchFor)
' If strSearchFor isn't found in strSearch
' just return the original string.
If lngFoundLoc = 0 Then
ReplaceString = strSearch
' If match is found, return original string up to match
' location, concatenate new text, and search the rest of
' the string recursively for additional matches.
Else
ReplaceString = Left(strSearch, lngFoundLoc - 1) & _
strReplaceWith & _
ReplaceString(Mid(strSearch, lngFoundLoc + _
lngLenRemove), strSearchFor, strReplaceWith)
End If
exit_ReplaceString:
Exit Function
' Print error to Debug window and don't interrupt query.
err_ReplaceString:
Debug.Print "Error Replacing String """ & _
strSearchFor & """ with """ & _
strReplaceWith & """ in text """ & _
strSearch & """"
' If there is an error, return original string
' and exit the function.
ReplaceString = strSearch
Resume exit_ReplaceString
End Function
Query: qryUpdateMemos
--------------------------------------------------------------------
Type: Update Query
Field: <Name of Memo Field>
Table: <Name of Table>
Update To:
ReplaceString([<Name of Memo Field>],[Search for],[Replace with])
Criteria:
Field: Instr(1,[<Name of Memo Field>], [Search for])
Update To:
Criteria: >0
Table: tblMemoTable
--------------------
Field Name: MemoText
Data Type: Memo
Indexed: No
Function FillMemo(strTableName As String, _
strFieldName As String)
Dim db As Database
Dim rs As Recordset
On Error GoTo Err_FillMemo
Set db = CurrentDb
Set rs = db.OpenRecordset(strTableName)
With rs
.AddNew
.Fields(strFieldName) = "abc" & String(2050, "x")
.Update
End With
db.Close
Exit_FillMemo:
Exit Function
Err_FillMemo:
MsgBox CStr(Err) & " " & Err.Description
Resume Exit_FillMemo
End Function
Additional query words: pra searching replacing
Keywords: kbbug kberrmsg KB173975