I cannot figure out why every time I open my calc document, this code throws a Function Sequence Error when called. Then the error resolves if I switch to design mode and back, and stays resolved unless i quit and reopen the document. But I need this to work without doing that so other people can use it!
The form in question is a reference to a single line of a table, it exists, is modifiable. It is defined and called and loaded before the line that throws the error. Pasting the code below, with a note on the line that throws the error.
Edited to say: It is assigned to Sheet Event > Activate Document, so it is called when I navigate to this sheet, but tested on other event as suggested, and still gets the error.
Sub LoadContactPage
Dim oSheet, oForm, oListB, oSubform As Object, nID As Integer
oSheet = ThisComponent.Sheets.getByName(“Contact”)
oForm = oSheet.getDrawpage().getForms().getByName(“Form”) ’ table tLookup, Key=2
oSubform = oForm.getByName(“Info”) ’ table tMember, linked by ID
oForm.reload()
oListB = oForm.getByName(“LBGroup”)
oListB.refresh()
oForm.reload()
nGrp = 0
sName = “”
nID = oForm.getInt(4) 'why does this get caught up on load??? Function sequence error???
If nID > 0 Then
nGrp = oSubform.getInt(4)
End If
sGroup = "Home Group: " & GetGrpWTwn(nGrp)
'show HG
oSheet.getCellByPosition(3, 6).setString(sGroup)
'set selected cell
ThisComponent.CurrentController.select( oSheet.getCellByPosition(0, 0) )
End Sub