Automated bullets

J

Jim

I'm using the code below found in another thread but having trouble with the
KeyPress code. When I'm in the text box typing the first bullet and hit
Enter to add a second bullet, the text box displays two bullets and deletes
my text. Can you see what I'm doing wrong??

Thanks!!


Private Sub Readout_Enter()
If Len(Trim([Readout])) > 0 Then
Me![Readout] = [Readout] + Chr$(13) & Chr(10) & "• "
Else
Me![Readout] = "• "
End If
End Sub


Private Sub Readout_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Me![Readout] = [Readout] + Chr$(13) & Chr(10) & "• "
End If
End Sub
 
M

Mike Painter

Jim said:
I'm using the code below found in another thread but having trouble
with the KeyPress code. When I'm in the text box typing the first
bullet and hit Enter to add a second bullet, the text box displays
two bullets and deletes my text. Can you see what I'm doing wrong??

Me! readout and Readout are not eh same. use Me! throughout.
Thanks!!


Private Sub Readout_Enter()
If Len(Trim([Readout])) > 0 Then
Me![Readout] = [Readout] + Chr$(13) & Chr(10) & ". "
Else
Me![Readout] = ". "
End If
End Sub


Private Sub Readout_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Me![Readout] = [Readout] + Chr$(13) & Chr(10) & ". "
End If
End Sub
 
J

Jim

Thanks for the suggestion. I changed it and still having the same issue. I
also tried using me. instead of me! with the same result. Using Access 2007.

Can you think of anything else that would cause that behavior?

Thanks,
Jim

Mike Painter said:
Jim said:
I'm using the code below found in another thread but having trouble
with the KeyPress code. When I'm in the text box typing the first
bullet and hit Enter to add a second bullet, the text box displays
two bullets and deletes my text. Can you see what I'm doing wrong??

Me! readout and Readout are not eh same. use Me! throughout.
Thanks!!


Private Sub Readout_Enter()
If Len(Trim([Readout])) > 0 Then
Me![Readout] = [Readout] + Chr$(13) & Chr(10) & ". "
Else
Me![Readout] = ". "
End If
End Sub


Private Sub Readout_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Me![Readout] = [Readout] + Chr$(13) & Chr(10) & ". "
End If
End Sub


.
 
M

Mike Painter

I get the same results in 2007.
But if you debug print the contents of me!readout it does contain all teh
information you have type in.
Thanks for the suggestion. I changed it and still having the same
issue. I also tried using me. instead of me! with the same result.
Using Access 2007.

Can you think of anything else that would cause that behavior?

Thanks,
Jim

Mike Painter said:
Jim said:
I'm using the code below found in another thread but having trouble
with the KeyPress code. When I'm in the text box typing the first
bullet and hit Enter to add a second bullet, the text box displays
two bullets and deletes my text. Can you see what I'm doing wrong??

Me! readout and Readout are not eh same. use Me! throughout.
Thanks!!


Private Sub Readout_Enter()
If Len(Trim([Readout])) > 0 Then
Me![Readout] = [Readout] + Chr$(13) & Chr(10) & ". "
Else
Me![Readout] = ". "
End If
End Sub


Private Sub Readout_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Me![Readout] = [Readout] + Chr$(13) & Chr(10) & ". "
End If
End Sub


.
 
M

Mike Painter

This "works" in an unbound text box but selects all the text so that would
have to be undone.
I also used shift enter since enter takes me to the next field in my system

Mike said:
I get the same results in 2007.
But if you debug print the contents of me!readout it does contain all
teh information you have type in.
Thanks for the suggestion. I changed it and still having the same
issue. I also tried using me. instead of me! with the same result.
Using Access 2007.

Can you think of anything else that would cause that behavior?

Thanks,
Jim

Mike Painter said:
Jim wrote:
I'm using the code below found in another thread but having trouble
with the KeyPress code. When I'm in the text box typing the first
bullet and hit Enter to add a second bullet, the text box displays
two bullets and deletes my text. Can you see what I'm doing
wrong??

Me! readout and Readout are not eh same. use Me! throughout.


Thanks!!


Private Sub Readout_Enter()
If Len(Trim([Readout])) > 0 Then
Me![Readout] = [Readout] + Chr$(13) & Chr(10) & ". "
Else
Me![Readout] = ". "
End If
End Sub


Private Sub Readout_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Me![Readout] = [Readout] + Chr$(13) & Chr(10) & ". "
End If
End Sub


.
 
J

Jim

Mike,

Thanks again for your help. I finally got the desired results by combining
your suggestion with Allen Browne's in another thread (to add a space after
the second bullet).

Here's the code I'm using now if anyone else needs it:

'On Enter code to add a bullet when the ReadoutNarrative field gets focus

Private Sub ReadoutNarrative_Enter()
If Len(Trim([ReadoutNarrative])) > 0 Then
Me.ReadoutNarrative = Me.ReadoutNarrative + Chr$(13) & Chr(10) & "• "
Else
Me.ReadoutNarrative = "• "
End If
End Sub


'On KeyDown code that adds a bullet and one space when you hit the Enter key
'from within the ReadoutNarrative field

Private Sub ReadoutNarrative_KeyDown(KeyCode As Integer, Shift As Integer)
Dim lngCursor As Long
If (KeyCode = vbKeyReturn) And (Shift = 0) Then
With Me.ReadoutNarrative
lngCursor = .SelStart
.SelText = vbCrLf & "• "
.SelStart = lngCursor + 3
Call InsertAtCursor(" ")
End With
KeyCode = 0
End If
End Sub

Mike Painter said:
Jim said:
I'm using the code below found in another thread but having trouble
with the KeyPress code. When I'm in the text box typing the first
bullet and hit Enter to add a second bullet, the text box displays
two bullets and deletes my text. Can you see what I'm doing wrong??

Me! readout and Readout are not eh same. use Me! throughout.
Thanks!!


Private Sub Readout_Enter()
If Len(Trim([Readout])) > 0 Then
Me![Readout] = [Readout] + Chr$(13) & Chr(10) & ". "
Else
Me![Readout] = ". "
End If
End Sub


Private Sub Readout_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Me![Readout] = [Readout] + Chr$(13) & Chr(10) & ". "
End If
End Sub


.
 

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