Brain Fart: copy string before hard return

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

Guest

My biorhythms must all be on the down cycle today because I can't seem to
figure this out or find the answer on my own...

I need to copy a string (strSubject field) from one form to another, but if
there's a hard return in the string, I only want to copy the portion of the
string before that.

This is Access 2000 if that matters... any help is greatly appreciated :)
 
Hard returns in Access are usually a carriage return followed by a line
feed. (Chr$(13) & Chr$(10), or the intrinsic constant vbCrLf)

Dim intReturn As Integer

intReturn = InStr(strSubject, vbCrLf)
If intReturn > 0 Then
Forms!MyForm!MyTextbox = Left$(strSubject, intReturn - 1)
Else
Forms!MyForm!MyTextbox = strSubject
End If
 
Worked like a charm, thanks a bunch!


Douglas J. Steele said:
Hard returns in Access are usually a carriage return followed by a line
feed. (Chr$(13) & Chr$(10), or the intrinsic constant vbCrLf)

Dim intReturn As Integer

intReturn = InStr(strSubject, vbCrLf)
If intReturn > 0 Then
Forms!MyForm!MyTextbox = Left$(strSubject, intReturn - 1)
Else
Forms!MyForm!MyTextbox = strSubject
End If
 
Back
Top