Navigating within Controls

  • Thread starter Thread starter Arthur Cunneen
  • Start date Start date
A

Arthur Cunneen

I am using SendKeys to add text to a memo field. I would
like to append new entries to values already contained in
the field. Is there anyway to send focus to the last word
in control?

(As a last resort, I can load the current contents of the
control into a variable, clear the control, then repost
the material in the variable to the control before
starting the SendKeys routine. However, this approach
causes wierd things to happen to any formating the
SendKeys entered earlier (e.g., paragraph seperations
created by SendKeys [using Chr(13) functions] seem to
duplicate on moving from the variable to the control).
 
Here's how I handle automatically adding text to a memo field. First, I put
the following statement in the memo field OnEnter event procedure:

MyMemoControlName.SelLength = 0

.... where "MyMemoControlName" is the name of the memo control on the form.

Next, I have a button below the memo control with the OnClick event
procedure set to:

On Error Resume Next
Me.SetFocus
DoCmd.GoToControl "MyMemoControlName"
SendKeys Now & " --> " '* Inserts the current date and time
SendKeys "^{ENTER}{LEFT}"
Err.Clear
On Error GoTo 0

Hope this example helps,
 
Arthur said:
I am using SendKeys to add text to a memo field. I would
like to append new entries to values already contained in
the field. Is there anyway to send focus to the last word
in control?

(As a last resort, I can load the current contents of the
control into a variable, clear the control, then repost
the material in the variable to the control before
starting the SendKeys routine. However, this approach
causes wierd things to happen to any formating the
SendKeys entered earlier (e.g., paragraph seperations
created by SendKeys [using Chr(13) functions] seem to
duplicate on moving from the variable to the control).


Why are you using SendKeys? That function is known to have
severe problems.

What's the problem with just using something like:

Me.thecontrol = Me.thecontrol & vbCrLf & strNewText
 
Back
Top