Ask Your Question
0

Base forms in basic

asked 2018-10-15 18:40:22 +0100

Pansmanser gravatar image

I wonder if someone can recommend a good reference to handling forms from basic macro. I am familiar with Andrew Pitonyak's OpenOffice.org Base Macro Programming, but I remain confused.

I have a series of Forms relating to a table with very long records and a basic macro passes control from one Form to the next. The macro must obviously update the record as it goes. If I understand correctly, first each field on the Form must be committed, and then the row updated (or inserted when the first Form creates the record in the table). However I get a variety of errors such as "Input required in field 'X'. Please provide a value" (although the field should not require an entry), 'Sequence error' and "Row set veto exception."

Exactly how should the values from the form be written to the table record?

Ubuntu 18.04 LO 6.1.2.1

edit retag flag offensive close merge delete

Comments

I'm not 100% sure, but I think sequence error seems to appear when you try and create another record, but before saving a modified record. I think I sometimes see it when inserting a new record, especially when inside a macro which does record work.

EasyTrieve gravatar imageEasyTrieve ( 2018-10-15 22:05:00 +0100 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2018-10-15 19:04:20 +0100

Ratslinger gravatar image

updated 2018-10-15 21:06:16 +0100

Hello,

The errors you are getting are because of a bug fix implemented in this LO version. Please see my answer in this post -> LibreOffice 6.1.2 Base value field problem.

When fields are initially created, the 'required' setting default is 'Yes'. The bug was ignoring the setting in previous versions. Setting to 'No' will correct.

If after changing you still get other errors, a sample with your code will be of help.

Edit:

Regarding other possible errors presented, it is possible you are not updating the record correctly. You need to verify if it is a new record or not:

  If oForm.IsNew Then
      oForm.insertRow()
  Else
      oForm.updateRow()
  End If

Have just re-tested this.

edit flag offensive delete link more

Comments

Thanks for reply, Ratslinger. But in fact I have set 'required' to 'no' and I still see 'value required.' It feels like the opposite of the bug 75341 - requiring input when specifically not required. And I have a little section of code identical to that above. As to attaching the code, as it stands the basic code and base forms are very extensive. If I have time, I'll try to strip it back to demonstrate the problem. I should have mentioned firebird in my post.

Pansmanser gravatar imagePansmanser ( 2018-10-16 13:33:25 +0100 )edit

@Pansmanser Have switched to LO 6.1.2.1 & using Firebird DB can generate your same errors. This is due to the mentioned bug. I hope you realize the setting being discussed is NOT in the table (Entry required). It is in each of the controls on the form - control properties on Data tab -> Input required. Your 'Sequence error' is something in the code. Moving from form to form with macros can be done in a number of ways so the sample will help. But please verify control settings.

Ratslinger gravatar imageRatslinger ( 2018-10-16 23:10:06 +0100 )edit

OK, thanks, Ratslinger. This is now solved. Combination of code too complicated for my own good and, as you suggested 'Input required' settings.

Pansmanser gravatar imagePansmanser ( 2018-10-17 11:15:23 +0100 )edit
0

answered 2018-10-15 19:40:55 +0100

EasyTrieve gravatar image

updated 2018-10-15 19:46:39 +0100

I put this page together of things i had looked at as I went along to help the next guy, who might be you at this moment.

The best advice I can give you are two things:

1) If you haven't already done so install MRI and learn to use it.

  • Start by creating a simple macro that calls MRI from an event and stops (see example below).
  • Hook this macro to the event that you think you want to use.
  • Start to explore with MRI by drilling down (by double clicking) into the object collection, or backing up (with the left arrow) and trying again.
  • Important places (methods) to look are model, parent, and getbyname.
  • Take some time to study all of the property values. Make sure you learn to be able to click on an object and get the interface help for it with the IDL Ref. button. (BTW, I still can't get MRI to correctly use the LibreOffice API. So for now I'm still using the OpenOffice API.)
  • Remember that each Property is derived from a Method. There are only methods in the UNO interface.

It took me awhile to learn to use MRI. I even rewrote parts of the MRI wiki at the git site once I finally understood it. MRI has been an immense help to me.

=== Object Catalog ===============================================================================  
My Macros & Dialogs
    MRILib
        Module1
            LoadMriLibrary
            Mri


=== My Macros & Dialogs / MRILib / Module1 =======================================================
Option Explicit 'BASIC  ###### MRI ######


' --- Helper to run Mri ------------------------------------
'   Usage: Mri [optional object to initially target]
'
Sub Mri( ByVal Optional MriTargetObject )
  On Error GoTo ShowError

    If IsMissing( MriTargetObject ) Then MriTargetObject = StarDesktop  'default target

    CreateUnoService( "mytools.Mri" ).inspect( MriTargetObject )
  Exit Sub

  ShowError:
    msgbox "Error: " & Error
End Sub


Private Sub OpenDocument()
    LoadMriLibrary
End Sub

=== Example: calling for testing =========================================================  

' --- Helper to load MRILib library ------------------------
Sub LoadMriLibrary()
  Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
End Sub

Private Sub SubForm_Grid_When_Recieving_Focus(oEvent As Object)
    mri oEvent: stop
End Sub

2) Spend some time reading everything you can find on the subject. The documentation is somewhat scattered. Unless this has changed some of the best help and technical documentation still comes from OpenOffiice rather than from LibreOffice.

edit flag offensive delete link more

Comments

Thank you EasyTrieve. Much food for thought and study. I am slightly familiar with mri, but lots to learn. When time permits ...

Pansmanser gravatar imagePansmanser ( 2018-10-16 15:46:18 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-10-15 18:40:22 +0100

Seen: 790 times

Last updated: Oct 15 '18