LO Base drop-down list and push button

Hi everyone. I have a question that I hope you can help me with.

I am using LO Base to create databases for various things that I do, and so far it has been working well for what I need it to do. There is one thing that I would like to do that I am not sure of.

I administer several copiers in my job, and each copier has a dedicated IP address. I would like to create a drop-down list in Base of all of the copiers that I administer, and when I choose the copier from the list, I would like to have a push button that takes me to the web administration page for that copier. (For example, if I wanted to administer copier 1 with IP of x.x.x.x, I would choose copier 1 from the list, click the button, and be taken to a web browser that goes to x.x.x.x. If I wanted to administer copier 2 with IP y.y.y.y, I would choose it from the list, click the button, and go to copier 2’s website and so on.)

I have done some macro work already, and I know how to use shell command to make the web browser go to the copier’s web pages, I just would like to know if there is a way to make the drop-down list and the push button work for each copier that I want to administer. I assume that I would need a macro to do that as well?

I want to mention that I am fairly new to LO Base.

Thank you for any help that you can provide.

Hello,

What you request is fairly simple but does require a small macro.

For ease of maintenance, place all items in a table: ID, Description, and URL

Example attached has one item (common to many) - 0, My Router, http://192.168.1.1

The list box will be based upon SQL with the first field as Description and second field as URL. Bound Field is 1. All is in properties of list box.

There is a push button. The Action property needs to be set to Open document/web page.

Finally there is the macro. This has the form and control names as used in the sample:

Option Explicit

Sub setTargetIP
    Dim oForm As Object, oControl As Object, sIPlocation As String
    oForm = ThisComponent.DrawPage.Forms.GetByName("MainForm")
    oControl = oForm.GetByName("lbAddresses")
    sIPlocation = oControl.ValueItemList(oControl.SelectedItems(0))
    oForm.getByName("PB1").TargetUrl = sIPlocation
End Sub

and is attached to the Changed event of the list box.

So the macro gets the internal form (MainForm). Using that it gets the list box (lbAddresses). From there obtains the URL from the chosen item. Then moves that to the push button so when pressed it will access (provided it is a valid URL) the requires address.

Sample ----- LBipRetrieve.odb

Base documentation is here

This is wonderful and works beautifully. Thank you. I can see the potential in this for other aspects I can use this for, If I wanted to do this for shell commands, can I use this code? Or would that be a bigger challenge? (Say I have several items in a table. I select an item, click the button, and a shell script runs. Or I click another item, click the button, and another shel script runs.)

@catipads.ccps,

Shell commands are different and vary with operating systems. Here are just a few posts:

opening a file with a macro given the path in URL form

On Linux: Macro executing shell command.

Base - how to set image control to save url as relative or absolute path

If you have further question on this please ask as a new question.