Place curser at end of a line

M

Macsmasher

Hi everybody,

Running Access07

I have a memo field that I will use as a journal. There is a cmd button
that I want to place the curser at the beginning of any existing text, insert
the UserName and date, then place the curser at the end of that new line so
the User can begin typing. The below code works fine with the exception of
placing the curser at the end of the line. Since using SendKeys "{END}" is
never a good idea, I need either something to replace it, or a suggestion on
how to do this differently.

strUser = Forms![frmSwitchboard]![txtCurrentUser] 'Pulling User from main
menu
With Me.memAdminNote
.SetFocus
.SelStart = 0
.SelText = vbNewLine & vbNewLine
.SelText = strUser & " " & Date & ": "
' replace SendKeys "{END}" with what???
End With

Thanks in advance for your input!

-Larry
Maximize Software, Inc.
 
C

Clif McIrvin

How about:

dim newString as string
With Me.memAdminNote
.SetFocus
.SelStart = 0
newString = vbNewLine & vbNewLine & _
strUser & " " & Date & ": "
.SelText = newString
.SelStart = len(newString)
' replace SendKeys "{END}" with what???
End With

--
Clif

Macsmasher said:
Hi everybody,

Running Access07

I have a memo field that I will use as a journal. There is a cmd
button
that I want to place the curser at the beginning of any existing text,
insert
the UserName and date, then place the curser at the end of that new
line so
the User can begin typing. The below code works fine with the
exception of
placing the curser at the end of the line. Since using SendKeys
"{END}" is
never a good idea, I need either something to replace it, or a
suggestion on
how to do this differently.

strUser = Forms![frmSwitchboard]![txtCurrentUser] 'Pulling User from
main
menu
With Me.memAdminNote
.SetFocus
.SelStart = 0
.SelText = vbNewLine & vbNewLine
.SelText = strUser & " " & Date & ": "
' replace SendKeys "{END}" with what???
End With

Thanks in advance for your input!

-Larry
Maximize Software, Inc.
 
C

Clif McIrvin

I hit send too soon ... there should be a
..SelLength = 0 in there as well.

--
Clif

Clif McIrvin said:
How about:

dim newString as string
With Me.memAdminNote
.SetFocus
.SelStart = 0
newString = vbNewLine & vbNewLine & _
strUser & " " & Date & ": "
.SelText = newString
.SelStart = len(newString) .SelLength = 0
' replace SendKeys "{END}" with what???
End With

--
Clif

Macsmasher said:
Hi everybody,

Running Access07

I have a memo field that I will use as a journal. There is a cmd
button
that I want to place the curser at the beginning of any existing
text, insert
the UserName and date, then place the curser at the end of that new
line so
the User can begin typing. The below code works fine with the
exception of
placing the curser at the end of the line. Since using SendKeys
"{END}" is
never a good idea, I need either something to replace it, or a
suggestion on
how to do this differently.

strUser = Forms![frmSwitchboard]![txtCurrentUser] 'Pulling User
from main
menu
With Me.memAdminNote
.SetFocus
.SelStart = 0
.SelText = vbNewLine & vbNewLine
.SelText = strUser & " " & Date & ": "
' replace SendKeys "{END}" with what???
End With

Thanks in advance for your input!

-Larry
Maximize Software, Inc.
 
M

Macsmasher

Thanks Clif. Worked like a charm!

-Larry

Clif McIrvin said:
I hit send too soon ... there should be a
..SelLength = 0 in there as well.

--
Clif

Clif McIrvin said:
How about:

dim newString as string
With Me.memAdminNote
.SetFocus
.SelStart = 0
newString = vbNewLine & vbNewLine & _
strUser & " " & Date & ": "
.SelText = newString
.SelStart = len(newString) .SelLength = 0
' replace SendKeys "{END}" with what???
End With

--
Clif

Macsmasher said:
Hi everybody,

Running Access07

I have a memo field that I will use as a journal. There is a cmd
button
that I want to place the curser at the beginning of any existing
text, insert
the UserName and date, then place the curser at the end of that new
line so
the User can begin typing. The below code works fine with the
exception of
placing the curser at the end of the line. Since using SendKeys
"{END}" is
never a good idea, I need either something to replace it, or a
suggestion on
how to do this differently.

strUser = Forms![frmSwitchboard]![txtCurrentUser] 'Pulling User
from main
menu
With Me.memAdminNote
.SetFocus
.SelStart = 0
.SelText = vbNewLine & vbNewLine
.SelText = strUser & " " & Date & ": "
' replace SendKeys "{END}" with what???
End With

Thanks in advance for your input!

-Larry
Maximize Software, Inc.
 
C

Clif McIrvin

Great!

Thanks for replying.

--
Clif

Macsmasher said:
Thanks Clif. Worked like a charm!

-Larry

Clif McIrvin said:
I hit send too soon ... there should be a
..SelLength = 0 in there as well.

--
Clif

Clif McIrvin said:
How about:

dim newString as string
With Me.memAdminNote
.SetFocus
.SelStart = 0
newString = vbNewLine & vbNewLine & _
strUser & " " & Date & ": "
.SelText = newString
.SelStart = len(newString) .SelLength = 0
' replace SendKeys "{END}" with what???
End With


--
Clif

message
Hi everybody,

Running Access07

I have a memo field that I will use as a journal. There is a cmd
button
that I want to place the curser at the beginning of any existing
text, insert
the UserName and date, then place the curser at the end of that
new
line so
the User can begin typing. The below code works fine with the
exception of
placing the curser at the end of the line. Since using SendKeys
"{END}" is
never a good idea, I need either something to replace it, or a
suggestion on
how to do this differently.

strUser = Forms![frmSwitchboard]![txtCurrentUser] 'Pulling User
from main
menu
With Me.memAdminNote
.SetFocus
.SelStart = 0
.SelText = vbNewLine & vbNewLine
.SelText = strUser & " " & Date & ": "
' replace SendKeys "{END}" with what???
End With

Thanks in advance for your input!

-Larry
Maximize Software, Inc.
 
M

Macsmasher

In the event it may help others, the cleaned up completed code looks like this:

Dim strUser As String
Dim strDateStamp As String

strUser = Forms!frmSwitchboard!txtCurrentUser
strDateStamp = strUser & " " & Date & ": "

With Me.memComments
.Locked = False
.SetFocus
.SelStart = 0
.SelText = vbNewLine & vbNewLine
.SelText = strDateStamp
.SelStart = Len(strDateStamp)
.SelLength = 0
End With


Clif McIrvin said:
Great!

Thanks for replying.

--
Clif

Macsmasher said:
Thanks Clif. Worked like a charm!

-Larry

Clif McIrvin said:
I hit send too soon ... there should be a
..SelLength = 0 in there as well.

--
Clif

How about:

dim newString as string
With Me.memAdminNote
.SetFocus
.SelStart = 0
newString = vbNewLine & vbNewLine & _
strUser & " " & Date & ": "
.SelText = newString
.SelStart = len(newString)
.SelLength = 0
' replace SendKeys "{END}" with what???
End With


--
Clif

message
Hi everybody,

Running Access07

I have a memo field that I will use as a journal. There is a cmd
button
that I want to place the curser at the beginning of any existing
text, insert
the UserName and date, then place the curser at the end of that
new
line so
the User can begin typing. The below code works fine with the
exception of
placing the curser at the end of the line. Since using SendKeys
"{END}" is
never a good idea, I need either something to replace it, or a
suggestion on
how to do this differently.

strUser = Forms![frmSwitchboard]![txtCurrentUser] 'Pulling User
from main
menu
With Me.memAdminNote
.SetFocus
.SelStart = 0
.SelText = vbNewLine & vbNewLine
.SelText = strUser & " " & Date & ": "
' replace SendKeys "{END}" with what???
End With

Thanks in advance for your input!

-Larry
Maximize Software, Inc.
 

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