I am running Libre Office 5.2.3.3. I have a form that I created in Base that posts a timestamp to a table; similar to a punch-clock.
After the user punches in or out, there is a MsgBox
confirmation message which the user then has to dismiss. I would like to replace the confirmation message with one that will self-dismiss after a few seconds.
I thought I could accomplish this by creating a label field
and control it’s visibility by adding a few more lines to the timestamp macro. I’ve spent loads of time googling and trying and testing. But I can’t seem to figure out the syntax. In particular, I believe I’m failing to properly address the label field. Below are several examples of code that do similar things.
example 1
adapted from: Access2Base - It's about converting PEOPLE, not data
sub GetControlVal
Dim ocControl As Object
ocControl = ofForm.Controls("confirm1")
MsgBox ocControl.Value
'ocControl.Visible = False
end sub
example 2
adapted from: [Solved] Hide control (View topic) • Apache OpenOffice Community Forum
sub HideButton3
dim button3 as object
Button3 = StarDesktop.CurrentComponent.DrawPage.Forms.GetByIndex(0).getByName("Push Button 3")
thiscomponent.currentcontroller.getcontrol(Button3).setVisible(False)
end sub
example 3
adapted from: [Solved] Form Control Visible/Invisible with macro (View topic) • Apache OpenOffice Community Forum
sub threeseconds
Doc = ThisComponent
Sheet = Doc.Sheets.getByIndex(0)
Page = Sheet.DrawPage
Form = Page.Forms.getByIndex(0)
'txtlabel is an object of type com.sun.star.comp.forms.OButtonModel
txtlabel = Form.getByName("confirm1")
'txtlabelCtrl is an object of type com.sun.star.comp.forms.OButtonControl
txtlabelCtrl = Doc.CurrentController.getControl(txtlabel)
'This can control object size, position, visibility, etc.
txtlabelCtrl.setVisible(False)
Wait 3000
txtlabelCtrl.setVisible(True)
end sub
example 4
adapted from: How to Hide/Unhide Field(s) on a Base Form or a SubForm
Function ToggleShowHide(ShowHideVariable As Boolean )
RootForm = ThisComponent.Drawpage.Forms
MainForm = RootForm.getByName("MainForm")
i = 0
Do While i < MainForm.Count
If Right(MainForm.getByIndex(i).ServiceName, 4) <> "Form" And _
Right(MainForm.getByIndex(i).Name, 6) <> "NoHide" Then
MainForm.getByIndex(i).EnableVisible = ShowHideVariable
End If
i = i + 1
Loop
End Function
I get the general idea, but it is not clear to me which method is the one I should be using, to implement this improved messagebox feature into Base with a macro.