Diane,
When you say the address contains 3, 4 or 5 lines, I assume you mean all 5
lines are contained in the same field, and that each line is separated by a
CrLf.
Each CrLf is represented by two ASCII characters; the carriage return (ASCII
13) and the linefeed (ASCII 10) - in that order. So a blank line can be
detected by the existence of the CrLf of the previous line plus the CrLf of
the blank line - two CrLf characters together. So all you need to do is
remove the two CrLf characters if they appear together. You can do that
using the Replace() function.
strMyAddress = Replace(rs!MyAddress, vbCrLf & vbCrLf, vbCrLf)
If you're doing it in a query, then the following will work.
SELECT Replace(MyAddress, Chr(13) & Chr(10) & Chr(13) & Chr(10), Chr(13)
& Chr(10)) As TheAddress FROM tblMyTable
Access versions prior to 2000 don't have a Replace function, so if you're
using these versions, you can replace the Replace function (no pun intended)
with this.
Public Function Repl(sExpression As String, _
sFind As String, sReplace As String) As String
Dim iPos As Integer
If Len(sExpression) > 0 And Len(sFind) > 0 Then
'Check to see if sFind exists
iPos = InStr(1, sExpression, sFind)
Do While iPos > 0
'It exists - replace it
Repl = Left(sExpression, iPos-1) & sReplace & _
Mid(sExpression, iPos + Len(sFind))
'As long as we're not at the end of sExpression,
'check to see if there is room for more instances
If iPos < Len(sExpression) Then
'Yep, there's room - check for sFind again
iPos = InStr(iPos + 1, sExpression, sFind)
Else
'Nope, there's no more room, so there can't be
'any more instances
iPos = 0
End If
Loop
Else
'There are no instances - set the return value = sExpression
Repl = sExpression
End If
End Function
Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html