The problem is how to get a form in a series of buttons linked to macros with predefined text values, where the press of a key value is inserted in the corresponding text field is where the mouse cursor. Clearly this should be possible to do it on different text fields in the form.
I enclose a sample file.
Thank you!
[Solved] Buttons for data entry form fields
[Solved] Buttons for data entry form fields
- Attachments
-
- Nuovo database.odb
- (15.26 KiB) Downloaded 155 times
Last edited by robce64 on Wed Feb 22, 2012 10:20 pm, edited 1 time in total.
OOo 3.3 Win7 64bit
Re: Buttons for data entry form fields
Code: Select all
Global nCursor As Long
Global sTextBox As String
Global oText As Object
Sub SingleLine_TextBox_StoreCursor (oEvent As Object) 'Text Box > Events > When Losing Focus
sTextBox = oEvent.Source.Model.Name
oText = oEvent.Source.AccessibleContext
nCursor = oText.CaretPosition
End Sub
Sub SingleLine_TextBox_Insert_Text1 (oEvent As Object) 'Button > Events > Execute
oText.insertText(("Hello World"),nCursor)
oForm = oEvent.Source.Model.Parent
oForm.GetByName(sTextBox).commit()
IF oForm.isnew THEN oForm.insertRow() ELSE oForm.updateRow()
End Sub
Sub SingleLine_TextBox_Insert_Text2 (oEvent As Object) 'Button > Events > Execute
oText.insertText(("Goodbye"),nCursor)
oForm = oEvent.Source.Model.Parent
oForm.GetByName(sTextBox).commit()
IF oForm.isnew THEN oForm.insertRow() ELSE oForm.updateRow()
End Sub
...
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria