Inserting Text at the Point of the Cursor (1 Viewer)

shadow9449

Registered User.
Local time
Today, 05:27
Joined
Mar 5, 2004
Messages
1,037
I have a list box with strings of data. There is a button underneath the list box that allows the user to select a string from the list box, click the button and the text gets moved into a memo box to the left of the list box. (Drag and drop would be really great here to make this work like all other programs but that's not going to happen in Access!)

The idea is to build a few paragraphs in the memo box based on different sentences in the list box.

The way I've implemented this is with a simple line of code like:

me.MyMemoBox = me.MyMemoBox & " " & me.ListBox

This works great but now I have a user saying that she wants to be able to put the cursor anywhere in middle of the text in the memobox, select a string from the list box and have the text get inserted at the point of the cursor rather than always going to the end of the existing text.

There are two ways I've thought of:

- Sendkeys can do this very easily but I do everything I can to not use Sendkeys as I know it's not reliable and reportedly doesn't work on Vista.

- If I could somehow find out where the cursor is (i.e. it's position from the beginning of the text) I could change the code to:

me.MyMemoBox = left(me.MyMemoBox, PositionOfCursor) & " " & me.ListBox & " " & right(me.MyMemoBox, PositionOfCursor)

The problem is that I don't know if a function exists to find the position of a cursor amid a string of text.

I would appreciate if someone could help me by either suggesting a function that would return the position of the cursor or suggesting another means to accomplish this.

Thank you

SHADOW
 

shadow9449

Registered User.
Local time
Today, 05:27
Joined
Mar 5, 2004
Messages
1,037
I just realized that this is going to be more difficult than I first realized. If you put the cursor in the memo field, then move to the list box, the cursor's position will be lost. You can't use any standard function (such as selstart) to find the position of the cursor. What a shame drag and drop doesn't work as it does in almost every other application :(

Any suggestions would be appreciated.

SHADOW
 

missinglinq

AWF VIP
Local time
Today, 05:27
Joined
Jun 20, 2003
Messages
6,423
Maybe someone else will have a solution, but I think your user is going to have settle for

  1. Right clicking on the listbox item (this will select the item)
  2. Clicking on Copy
  3. Clicking on the memo box in the insert position
  4. Right clicking
  5. Clicking on Paste
Your user has to remember that Access is a database program, not a word processing program.
 

shadow9449

Registered User.
Local time
Today, 05:27
Joined
Mar 5, 2004
Messages
1,037
Maybe someone else will have a solution, but I think your user is going to have settle for

  1. Right clicking on the listbox item (this will select the item)
  2. Clicking on Copy
  3. Clicking on the memo box in the insert position
  4. Right clicking
  5. Clicking on Paste
Your user has to remember that Access is a database program, not a word processing program.

I've disabled the ability to right-click BUT you've given me some ideas to experiment with :)

While Access is a database program, users are used to other database programs they use having a more complete feature set.

Thanks!

SHADOW
 

shadow9449

Registered User.
Local time
Today, 05:27
Joined
Mar 5, 2004
Messages
1,037
What I did in the end was copy the sentence from the listbox to the clipboard using Dev Ashish's copy function and then paste it in the memo box using docmd.runcommand accmdPaste. The user just has to double click where she wants it to be pasted.

Thanks for the idea.

SHADOW
 

Users who are viewing this thread

Top Bottom