Error in Super Easy Word Merge Code

G

Guest

Hi,

I have been using the Super Easy Word Merge found
http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html

It worked last week but now it comes up with the following error:
Run-time error '6':
Overflow

Does anyone know what this means?

When I click on Debug it takes me to the following highlighted line:

intFoundPos = InStr(vText, strSearchFor)

This section of code is:

Function strDReplace(vText As String, strSearchFor As String, strReplaceTo
As String) As String

Dim intFoundPos As Integer
Dim intSearchLen As Integer
Dim intReplaceLen As Integer

intSearchLen = Len(strSearchFor)
intReplaceLen = Len(strReplaceTo)

intFoundPos = InStr(vText, strSearchFor)

Do While intFoundPos > 0
vText = Left$(vText, intFoundPos - 1) & strReplaceTo & Mid(vText,
intFoundPos + intSearchLen)
intFoundPos = InStr(vText, strSearchFor)
Loop

strDReplace = vText

End Function
 
T

Terry Kreft

The simple fix would probably be replace the line
Dim intFoundPos As Integer

with
Dim intFoundPos As Long
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top