I have this macro, that works very well for setting a field called “Sortkey” from one called “Name”:
sub setKey (e as object)
dim oDoc, oDrawpage, oForm, oName, oSortKey, oConnection as object
dim wSort as string
oDoc = thisComponent
oDrawpage = oDoc.drawpage
oForm = oDrawPage.forms.getByName("MainForm")
oName = oForm.getByName("txtName")
oSortKey = oForm.getByName("txtSortKey")
wSort = oName.text
if left(wSort, 1) = """" then
wSort = mid(wSort, 2)
if right(wSort, 1) = """" then wSort = left(wSort, len(wSort) - 1)
endif
oSortKey.BoundField.updateString(wSort)
end sub
I have absolutely no idea where I found “oSortKey.BoundField.updateString(wSort)”
Now, I want to do something similar with another field, to programmatically set the value of a checkbox. Here is what I have so far:
sub setBlocked (e as object)
dim oDoc, oDrawpage, oForm, oStatus, oShitlist, oConnection as object
dim wCheckBox as boolean
oDoc = thisComponent
oDrawpage = oDoc.drawpage
oForm = oDrawPage.forms.getByName("MainForm")
oStatus = oForm.getByName("txtStatus")
oBlocked = oForm.getByName("cbBlocked")
wCheckBox = InStr(oStatus.text, "permanent") > 0 or InStr(oStatus.text, "suspended") > 0
msgBox(wCheckBox)
oBlocked.BoundField.updateState(wCheckBox)
end sub
I tried updateCheckBox, updateState, updateValue, updateBoolean, and just plain update. Whatever I try, the msgBox fires with the correct Boolean value, but then it comes back with "Object variable not set.
What is it I’m looking for? And where is it documented?