Here is the problem and the context:
.
When I add a new record in my DB forms, it does not save automatically unless I click the “Save” button on the navigation bar to permanently insert it into the intended table field.
.
Sometimes, without having saved this new addition, I enter data in various fields or I click certain buttons associated with various tasks. Having not previously saved this addition, clicking certain buttons generates this error:
BASIC runtime error.
An exception occurred:
Type: com.sun.star.sdbc.SQLException
Message: The cursor is pointing before the first line or after the last line.
The clicked button is associated with this Basic macro:
' This procedure allows you to display a recording, i.e. the starting recording.
Sub FindRecord(oForm As Object, iTarget As Integer)
Dim iRow As Integer
Dim oColumn As Object, oResultSet As Object
Dim sFormName As String
sFormName = oForm.Name
If sFormName = gcFrmActors Then
oResultSet = oForm.createResultSet
oColumn = oResultSet.columns.getByName(gcColActorID)
ElseIf sFormName = gcFrmActresses Then
oResultSet = oForm.createResultSet
oColumn = oResultSet.columns.getByName(gcColActriceID)
Else
oResultSet = oForm.createResultSet
oColumn = oResultSet.columns.getByName(gcColFSID)
End If
oResultSet.Absolute(1)
Do
If oColumn.getInt = iTarget Then
iRow = oResultSet.Row
Exit Do
End If
oResultSet.Next
Loop
oForm.Reload()
oForm.Absolute(iRow)
End Sub
The line of code generating the error is as follows:
If oColumn.getInt = iTarget Then
I know that by saving the new addition in the form it prevents this error. However, would it be possible to prevent this error in the case where we click the button but have forgotten to save this addition?
.
In fact, this macro is looking for a record that has not been saved, so it is impossible to find the ID associated with this new addition. Is it possible to prevent this error?