Carriage return

B

Brad

Thanks for taking the time to read my question.

I am making a form that is a keyboard and I want to have an Enter button
that acts like a carriage return chr(13) or chr(10). Using 13 or 10 does not
seem to work for me. The values I type are going into a text box that is data
type Memo.

Any ideas how I can accomplish this?

Brad

CODE:

I pass TheLetter from the letters on the keyboard cmdA_Click for example. It
checks if it's supposed to be CAPS or not and then passes the proper value to
the function. The Enter key passes "Enter".

Function AddText(TheLetter As Variant)
If Me.Notes = "" Then
If TheLetter = "Enter" Then
Me.Notes = Chr(13) 'trying to add a carriage return here
Else
Me.Notes = TheLetter
If Me.chkShift = True Then
Me.chkShift = False
ChangeCase
End If
End If
Else
If TheLetter = "Enter" Then
Me.Notes = Me.Notes & Chr(13) 'trying to add a carriage return
here
Else
Me.Notes = Me.Notes & TheLetter
End If
If Me.chkShift = True Then
Me.chkShift = False
ChangeCase
End If
End If

End Function
 
F

fredg

Thanks for taking the time to read my question.

I am making a form that is a keyboard and I want to have an Enter button
that acts like a carriage return chr(13) or chr(10). Using 13 or 10 does not
seem to work for me. The values I type are going into a text box that is data
type Memo.

Any ideas how I can accomplish this?

Brad

CODE:

I pass TheLetter from the letters on the keyboard cmdA_Click for example. It
checks if it's supposed to be CAPS or not and then passes the proper value to
the function. The Enter key passes "Enter".

Function AddText(TheLetter As Variant)
If Me.Notes = "" Then
If TheLetter = "Enter" Then
Me.Notes = Chr(13) 'trying to add a carriage return here
Else
Me.Notes = TheLetter
If Me.chkShift = True Then
Me.chkShift = False
ChangeCase
End If
End If
Else
If TheLetter = "Enter" Then
Me.Notes = Me.Notes & Chr(13) 'trying to add a carriage return
here
Else
Me.Notes = Me.Notes & TheLetter
End If
If Me.chkShift = True Then
Me.chkShift = False
ChangeCase
End If
End If

End Function

In Access, you MUST use both
chr(13) & chr(10)
in that order.
Or, if you are using VBA (as you are), you can use the above or the
VBA constants vbCrLf or vbvNewLine.

I can't say that I understand what you are doing with the rest of your
code.

So you can use either:
Me.Notes =Me.[Notes] & Chr(13) & Chr(10)
or
Me.Notes = Me. [Notes] & vbNewLine
or
Me.Notes = Me. [Notes] & vbCrLf
 
D

Dirk Goldgar

Brad said:
Thanks for taking the time to read my question.

I am making a form that is a keyboard and I want to have an Enter button
that acts like a carriage return chr(13) or chr(10). Using 13 or 10 does
not
seem to work for me. The values I type are going into a text box that is
data
type Memo.


Access represents a new line by the *combination* of carriage return --
Chr(13) -- and line feed -- Chr(10) -- in that order. You can either
concatenate them together:

MyText = MyText & Chr(13) & Chr(10)

.... or you can use either of these defined constants:

vbCrLf
vbNewLine
 

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