Base Form Reload Refresh Issues

Win10 LO 7.1.4 HSQL 2.51

Hi,

Am experimenting with a simple dialog to update clear or simply read a limited size field in a table control.
The dialog is working fine however there are some issues with the form.

Normal procedure when the form lists all records, the macro behind the dialog does an update and reloads the form – jumping to row one.

Now I would like to stay on the same record with the focus still in the notes field.
Can not use the …absolute(nrow) since the data source is sorted by date thus leaving the id s all over the place.

Can not use selected row() since no row is selected.

Is there a way to get the row number to a variable ? Tried a sequence to no avail.

Moreover if the form is filtered to show future dates only, reload will cause sql error not being able to jump to the top row.
Looking forward to any pointers, thanks

as a code snippet

Sub gotoRecord()
Dim oForm2,RCD As object
Dim i as integer

oForm2 = thiscomponent.getDrawPage().getForms().getByName("MainForm")
RCD = oForm2.getByName("MainForm_Grid").getRowSet()

i = RCD.getColumns().getByName("ID").getInt()

'
'  form reload here
'

RCD.first())
while i <> RCD.getColumns().getByName("ID").getInt() and not RCD.isAfterLast():
    RCD.next()
wend

End Sub

results my vary depending upon number of records in the form and speed to jump to the next record, sometimes a wait(200) is required

Thank you, will give it a shot.

@parsely

working like a treat ! However recordpointer at the correct row with no field selected. Enter will open the dialog again. So how would I set the focus to the notes field once the loop is done.

Nice, is the notes field outside the MainForm_Grid (the cursor position in the picture), or is it a column within the mainformgrid?

The notes field is part of the grid. By clicking the button outside (above) I get the data for the dialog. The filter issue is resolved by removing any before the reload. See Cloud loggin user adm pw adm

this covers the moving of the record pointer and setting the focus to a column in the grid, first column has index=0.
A wait instruction can be necessary to let the form adjust the recordpointer and keep the form execution up with the execution speed of the macro. Either moving to RCD.first() or in the loop RCD.next()


    Sub gotoRecord()
	Dim oForm2,RCD As Object
	Dim oField, oDocView, oControlView As object

    oForm2 = thiscomponent.getDrawPage().getForms().getByName("MainForm")
    RCD = oForm2.getByName("MainForm_Grid").getRowSet()

	i =  RCD.getColumns().getByName("ID").getInt()

	'
	'  form reload here
	'

    RCD.first()
    while i <> RCD.getColumns().getByName("ID").getInt() and not RCD.isAfterLast():
        RCD.next()
    wend


'  optional: in case the control is on the mainform
'   oField = oForm2.getByName("test")
'   oDocView = thiscomponent.getCurrentController()
'   oDocView.getControl(oField).setFocus()

' when its within the grid:
    oForm2 = oForm2.getByName("MainForm_Grid")

    oControlView = thisComponent.getCurrentController().getControl(oForm2)
    oControlView.setCurrentColumnPosition(3)  'visible column 4
    oControlView.setFocus()


End Sub

Fantastic, thanks for that!