[Solved] Buttons for data entry form fields

Discuss the database features
Post Reply
robce64
Posts: 20
Joined: Wed Feb 22, 2012 8:27 pm

[Solved] Buttons for data entry form fields

Post by robce64 »

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.
:super:
Thank you!
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
User avatar
DACM
Volunteer
Posts: 1138
Joined: Tue Nov 03, 2009 7:24 am

Re: Buttons for data entry form fields

Post by DACM »

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 
See also: notes.odb for some multi-line text box examples.
...
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
robce64
Posts: 20
Joined: Wed Feb 22, 2012 8:27 pm

Re: Buttons for data entry form fields

Post by robce64 »

Thank you!
:bravo: :bravo: :bravo: :bravo: :bravo: :bravo: :bravo:
:super: :super: :super: :super: :super: :super: :super:
OOo 3.3 Win7 64bit
Post Reply