Inserting bullets into text box

S

Steve Albert

I am using Access 2003. I would like to use vba code so that when a user
clicks in an empty text box, a bullet (Alt-0149) is inserted first and then
the user can enter text. When the user then hits the enter key, another
bullet is inserted and they can type more text. If there is text already in
the text box, then clicking inside the box will not add an initial bullet,
but if you hit enter, a new bullet will be inserted.

I was able to program a bullet to be inserted when you click in the text
box, but can't get further. Any help would be appreciated. - Steve

Private Sub ActionsComp1_Enter()
If Len(Trim([ActionsComp1])) > 0 Then
Me![ActionsComp1] = [ActionsComp1] + Chr$(13) & Chr(10) & "• "

Else
Me![ActionsComp1] = "• "

End If

End Sub
 
P

PJFry

The On Enter event runs when a control first gets the focus. What you would
need to do is to have Access evaluate each key press to see if the key
pressed is the Enter key. If it is, then insert a bullet point.

You would keep the On Enter Event with the change below:

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

End Sub

Then on the On Key Press Event:

Private Sub ActionsComp1_KeyPress(KeyAscii As Integer)
'Checks to see if the key pressed in the Enter Key.
If KeyAscii = 13 Then
'Double check this to make sure it does what you want it to do:
Me![ActionsComp1] = [ActionsComp1] + Chr$(13) & Chr(10) & "• "
End If

End Sub

Now, with that being said, I really don't think this a good idea. What I
provided may end up being very buggy. I have never used the KeyAscii in this
context. Would it be more appropriate to save the data currently separated
by the bullets as individual records? You could then use a sub-form to store
each item.

PJ
 
S

Steve Albert

Hi PJ,

I modified the KeyPress sub to:

If KeyAscii = 13 Then
'Double check this to make sure it does what you want it to do:
Me![ActionsComp1] = "• "
End If

It works fine. Right now, I do not see any bugs. Thanks so much!

- Steve

PJFry said:
The On Enter event runs when a control first gets the focus. What you would
need to do is to have Access evaluate each key press to see if the key
pressed is the Enter key. If it is, then insert a bullet point.

You would keep the On Enter Event with the change below:

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

End Sub

Then on the On Key Press Event:

Private Sub ActionsComp1_KeyPress(KeyAscii As Integer)
'Checks to see if the key pressed in the Enter Key.
If KeyAscii = 13 Then
'Double check this to make sure it does what you want it to do:
Me![ActionsComp1] = [ActionsComp1] + Chr$(13) & Chr(10) & "• "
End If

End Sub

Now, with that being said, I really don't think this a good idea. What I
provided may end up being very buggy. I have never used the KeyAscii in this
context. Would it be more appropriate to save the data currently separated
by the bullets as individual records? You could then use a sub-form to store
each item.

PJ


Steve Albert said:
I am using Access 2003. I would like to use vba code so that when a user
clicks in an empty text box, a bullet (Alt-0149) is inserted first and then
the user can enter text. When the user then hits the enter key, another
bullet is inserted and they can type more text. If there is text already in
the text box, then clicking inside the box will not add an initial bullet,
but if you hit enter, a new bullet will be inserted.

I was able to program a bullet to be inserted when you click in the text
box, but can't get further. Any help would be appreciated. - Steve

Private Sub ActionsComp1_Enter()
If Len(Trim([ActionsComp1])) > 0 Then
Me![ActionsComp1] = [ActionsComp1] + Chr$(13) & Chr(10) & "• "

Else
Me![ActionsComp1] = "• "

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