Adding a carriage return to a text field

G

Guest

Hi, I'm trying to add a "ctrl+enter" to a text field, but not manually, I
take the text in the DETAIL_DESC field, and add it to the DETAIL_HIST field.
Each time I add a new DETAIL_DESC.value to DETAIL_HIST, I want a new row. Can
you help me?

Private Sub DETAIL_DESC_Exit(Cancel As Integer)

Dim TEXT1 As String
Dim TEXT2 As String
Dim MODIF As String
Dim SUBMIT As String

TEXT2 = DETAIL_HIST.Value
TEXT1 = DETAIL_DESC.Value
MODIF = Now()
SUBMIT = SUBMITTER.Value

DETAIL_HIST.Value = (TEXT2 + "CTRL+ENTER" + MODIF + SUBMIT + TEXT1)
DETAIL_DESC.Value = ""

End Sub
 
F

fredg via AccessMonster.com

You are concatenating the values not performing an addition!
The symbol to concatenate is the ampersand (&) not the plus (+).
Also, the value property of a text control is the default property.
You do not need to explicitly write it.

Private Sub DETAIL_DESC_Exit(Cancel As Integer)

Dim TEXT1 As String
Dim TEXT2 As String
Dim MODIF As String
Dim SUBMIT As String

TEXT2 = DETAIL_HIST
TEXT1 = DETAIL_DESC
MODIF = Now()
SUBMIT = SUBMITTER

[DETAIL_HIST] = (TEXT2] & vbCrLf & [MODIF] & [SUBMIT] & [TEXT1]
DETAIL_DESC = ""

End Sub

Note: it would be more readable if you add a comma and space between each
of the last 3 items:

DETAIL_HIST = TEXT2 & vbCrLf & MODIF & ", " & SUBMIT & ", " & TEXT1

Also, Now() returns a Date and Time numeric value (i.e. 32895.258963), not
a string, so I would either change the MODIF to Date datatype and format
the Now as wanted, or not use it at all and substitute a formatted Now
value directly in your contcatenation instead of MODIF.

[DETAIL_HIST] = TEXT2 & vbCrLf & Format(Now,"mmmm d, yyyy hh:nn:ss") & ", "
& SUBMIT & ", " & TEXT1

Fred
 

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