

'Return: True if characters were inserted. 'Purpose: Insert the characters at the cursor in the active control.
#ASP.NET INSERT MOUSE COORDINATES INTO TABLE CODE#
Here is the code to copy into a standard module in your database: Public Function InsertAtCursor(strChars As String, Optional strErrMsg As String) As Boolean If (Shift = acAltMask) And Ke圜ode = vbKeyD Then In a memo field, you may want to insert a new line and today's date when Alt+D is pressed Private Sub Text5_KeyDown(Ke圜ode As Integer, Shift As Integer) Note that you cannot use a command button on the form to do this: when its Click event runs, it has focus, and the attempt to insert text into the command button cannot succeed. You could allow the user to define their own paragraphs (stored in a table), and use DLookup() to retrieve the values to insert. MsgBox strMsg, vbExclamation, "Problem inserting boilerplate text"įor a variation on the above, you could create a buttons on a custom toolbar/ribbon that insert the paragraphs. Private Sub Text0_KeyDown(Ke圜ode As Integer, Shift As Integer) This example inserts preset paragraphs at the cursor as the user presses Alt+1, Alt+2, etc. If (Ke圜ode = vbKeyTab) And (Shift = 0) Then

Use the KeyDown event procedure of your text box, like this: Private Sub txtMemo_KeyDown(Ke圜ode As Integer, Shift As Integer) To simulate this, you could insert 4 spaces when the user presses the Tab key. In Access, the Tab key does not insert a tab character as it does in Word. Here are some examples of how the function could be used. That is in keeping with what normally happens in Windows programs. If any characters are selected at the time you run this code, those characters are overwritten.

You can then call it from anywhere in your database to insert characters into the active control, at the cursor position. Provided by Allen Browne, January 2008 Insert characters at the cursorĬopy the function below into a standard module in your database.
