Is there an alternative to the REPLACE function for AC97?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please tell me there is an alternative - I'm almost done with this program..
and I need to deal with offending apostrophe's

Funny because I'm using VBA in another program which has it,
but the main database in Access97 does not


'===============
Replace(NewData, "'", "''")


Thanks
 
jonefer said:
Please tell me there is an alternative - I'm almost done with this
program.. and I need to deal with offending apostrophe's

Funny because I'm using VBA in another program which has it,
but the main database in Access97 does not


'===============
Replace(NewData, "'", "''")

The Replace function wasn't introduced until Access 2000, so here's a
replacement for it that you can use in Access 97:

'----- start of code -----
Public Function Replace( _
Expression As String, _
Find As String, _
Replacement As String, _
Optional ByVal Start As Long = 1, _
Optional ByVal Count As Long = -1, _
Optional Compare As Long = vbBinaryCompare) _
As String

' Functional equivalent of the A2K Replace() function, to be used
when
' that function is not available.

Dim strResult As String
Dim lngFL As Long
Dim lngPos As Long

If Count < -1 Then Err.Raise 5

lngFL = Len(Find)
If lngFL > 0 Then
Do Until Count = 0
lngPos = InStr(Start, Expression, Find, Compare)
If lngPos = 0 Then Exit Do
strResult = strResult & _
Mid$(Expression, Start, lngPos - Start) & _
Replacement
Start = lngPos + lngFL
Count = Count - 1
Loop
End If

Replace = strResult & Mid$(Expression, Start)

End Function
'----- end of code -----
 
Back
Top