Bug 50599

Summary: Macros: NoSuchElementException during normal work on new record
Product: LibreOffice Reporter: Mateusz <mateusz.dobrowolny>
Component: BASICAssignee: Not Assigned <libreoffice-bugs>
Status: RESOLVED NOTABUG QA Contact:
Severity: normal    
Priority: medium    
Version: 3.5.4 release   
Hardware: x86-64 (AMD64)   
OS: Windows (All)   
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 41884    

Description Mateusz 2012-06-01 15:14:33 UTC
I have this problem when:
1. On Form I have two forms, each attached to the different table
2. I am inserting new row in sub-form, by editing list boxes, and date list boxes.
NOTE: The subform is joined to the main table by master - slave field.
3. When I click on the drop-down button on date list box (one field in my table stores date), this exception occures:

Type: com.sun.star.container.NoSuchElementException

And I have no macro, just editing NewRow in my table.
To get this exception caught I had to add a macro to the "Before Record Action" event (see below).
The problem is that I simply click on the date control. Or sometimes double-click the form (not any specific control) - and the whole LibreOffice crashes and the I had to recover the file.


Function prevent_saving_uncompleted_record (oEvent As Object)
REM When clicking on the Form during record modification/creation, Libre Office unexpectedly attempts to save uncompleted record
REM Because of that this function is set on the "Before record action" event to prevent saving a record during modifications.
	REM Set up error handler
	On error GoTo ErrorHandler

	REM By default all modifications to the row are not allowed
	prevent_saving_uncompleted_record = True
Dim oForm As Object
Dim oControl As Object
	oForm = oEvent.Source.Model
	oControl = oForm.GetByName("Save button")
	REM Check if "Save button" is enabled (it is enabled when any of the field has changed)
	If oControl.Enabled = "True" Then
		prevent_saving_uncompleted_record = False
	End If
	Exit Function
	
	ErrorHandler:
	MsgBox "Error " & err & ": " & error$ + chr(13) + "In line : " + Erl + chr(13) + Now , 16 ,"An error occurred"
End Function
Comment 1 Mateusz 2012-06-07 01:01:48 UTC
It was my fault. Still learning ... :)
Crash will be logged into separate issue. Here I had a wrong control name.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.