S
Southern at Heart
I have the below routine to remove any trailing returns from the specified
field. The Table name and the Field name in that table are passed to this
code. Would it be easy to modify this code so that if I passed the * sign or
the word "ALL" or something like that, as the strField, that the code would
remove the trailing returns from all the fields in the specified table? This
would save me LOTS of extra lines.
thanks,
SouthernAtHeart
Sub Remove_Trailing_Returns(strTable As String, strField As String)
Dim strSQL As String
Dim db As DAO.Database
Dim qd As DAO.QueryDef
Set db = CurrentDb
strSQL = "UPDATE " & strTable & " SET " & strTable & "." & strField & " =
Left(" & _
strField & ",Len(" & strField & ")-2) WHERE (((" & strTable & "." & _
strField & ") Like ""*"" & Chr(13) & Chr(10)));"
Set qd = db.CreateQueryDef("", strSQL) ' create an unnamed, unsaved query
StartOver:
qd.Execute
Debug.Print qd.RecordsAffected
If qd.RecordsAffected <> 0 Then GoTo StartOver
End Sub
field. The Table name and the Field name in that table are passed to this
code. Would it be easy to modify this code so that if I passed the * sign or
the word "ALL" or something like that, as the strField, that the code would
remove the trailing returns from all the fields in the specified table? This
would save me LOTS of extra lines.
thanks,
SouthernAtHeart
Sub Remove_Trailing_Returns(strTable As String, strField As String)
Dim strSQL As String
Dim db As DAO.Database
Dim qd As DAO.QueryDef
Set db = CurrentDb
strSQL = "UPDATE " & strTable & " SET " & strTable & "." & strField & " =
Left(" & _
strField & ",Len(" & strField & ")-2) WHERE (((" & strTable & "." & _
strField & ") Like ""*"" & Chr(13) & Chr(10)));"
Set qd = db.CreateQueryDef("", strSQL) ' create an unnamed, unsaved query
StartOver:
qd.Execute
Debug.Print qd.RecordsAffected
If qd.RecordsAffected <> 0 Then GoTo StartOver
End Sub