Code In LibreOffice Base - Simple Form

Sdílet
Vložit
  • čas přidán 5. 08. 2024
  • Learn how to program a form in LibreOffice (open office) base.
    LibreOffice (Open Office) Base programming book with reviews (affiliate) amzn.to/35wqtuI
    ☕ Ko-FI Support ... ko-fi.com/seanbjohnson ☕ or buymeacoffee www.buymeacoffee.com/seanjohnson ☕
    How to create a simple record navigation form in LibreOffice base.
    This tutorial will get you started with the basics of programming in LibreOffice.
    This lesson covers creating a form, adding two text box controls and two button controls onto the base form.
    Then I show you how to set the properties of the form and controls correctly.
    You will then learn how to get into the Open Office (LibreOffice) macro editor and create a code module in the standard library to write code for the form.
    I then show you how to add code to the navigation buttons I placed on the form.
    We make use of the code pasted below by adding it to the form code module.
    Video on how to create a LibreOffice Form with SubForm • How To Create A LibreO...
    All my LibreOffice Tutorial videos can be seen at this link • How To download Libre ...
    LibreOffice and OpenOffice macros are similar to Microsoft VBA, main differences are that Microsoft has IntelliSense and a different API.

    If you found this tutorial helpful consider supporting this channel with a steaming hot cup of coffee... buymeacoffee.com/seanjohnson

    The code referred to in the video is below ...
    Private Function getFormFromEvent(e as Object) as Object
    Dim szModuleRoutineName as String
    szModuleRoutineName = "m_frmMoveRecord.GetFormFromEvent"
    On Error Goto ErrorCheck
    select case e.Source.ImplementationName
    case "com.sun.star.form.FmXFormController"
    GetFormFromEvent = e.source.model
    case "com.sun.star.form.OButtonControl"
    GetFormFromEvent = e.source.model.parent
    case "com.sun.star.comp.forms.ODatabaseForm"
    GetFormFromEvent = e.source
    case else
    msgbox e.Source.ImplementationName
    msgbox "Unknown event in mSwitchboard.LoadMainKeywordFile"
    msgbox "Need to look at the locals window to trace up the stack" & chr(13) & "to find the form reference."
    end select
    Exit Function
    ErrorCheck:
    MsgBox "Error in " & szModuleRoutineName & chr(13) & "Error Number: " & err & " " & Error$ & chr(13) & "Error Line : " & erl
    End Function
    In This Video
    -------------------------
    Cameras Used Canon 70D ebay.us/YyjzeV
    Lens EFS 18-135 ebay.us/WoGVpr
    Microphone Rode NT-USB ebay.us/BvsfcA
    Latest Gear
    ---------------------
    Video Production
    ===============
    Sony Camera: amzn.to/3mqyqfu
    Elgato HDMI Stream Capture: amzn.to/2Yfyrum
    Microphones
    ---------------
    Screen Casting: amzn.to/3a2TnHN
    Microphone and Arm : amzn.to/3iwvL2S
    Talking To Camera: amzn.to/3FqXI6b
    Video Kit
    -------------
    Lights
    Elgato video Lights: amzn.to/3sSK3xg
    Background Light: amzn.to/3uTXyPh
    Note Taking
    --------------
    Rocketbook reusable notebook amzn.to/3sSK3xg
    #libreoffice #openoffice
    DISCLAIMER: This video and description contain affiliate links, this means if you click on one of the product links, I'll receive a small commission.
  • Věda a technologie

Komentáře • 43

  • @woxz1
    @woxz1 Před 3 lety +3

    This video has triggered me to learn more about libreoffice base, thank you .

    • @BusinessProgrammer
      @BusinessProgrammer  Před 3 lety +1

      You're welcome Heri, Base is great because It's free, works on mac, pc and Linux and made by people who want to put something great out there. It's my goto for personal projects.

  • @LibreOfficeHispano
    @LibreOfficeHispano Před 11 měsíci

    Great video as always! Thanks, Sean!!!

    • @BusinessProgrammer
      @BusinessProgrammer  Před 11 měsíci

      My pleasure!, I see you've got your own channel going also.. ;-)

  • @kychemclass5850
    @kychemclass5850 Před 2 lety +1

    Hi Sean. Thanks for sharing your knowledge on this.

  • @gonzalezcloud4696
    @gonzalezcloud4696 Před rokem +2

    Hi, Mr. Johnson. WONDERFUL step-by-step videos that make it seem so easy! 🙂
    I really enjoyed watching how to create dynamic image controller in your other video.
    Suggestion for a future video:
    I would like to know how to create two date fields that automatically populate for:
    * CreationDate field (that displays the date a record was created).
    * LastUpdate field (that displays the date a record was last modified).

  • @achimbenoit9467
    @achimbenoit9467 Před rokem

    Great Teacher!!! Congrats!!!

  • @rheung3
    @rheung3 Před 3 lety

    Good tutorial, many thanks.

  • @delanewise9070
    @delanewise9070 Před 2 lety +2

    Sean,
    Great videos and great software. I too have the Basic Base Programming book but as you said it can be tough to understand if you are not a programmer. Some of the things I struggle with are a basic CRUD form (create, read, update, delete,) … I have some MySql views I want to update and LibreOffice cannot update a view. You can via code I understand. A video on getting data from a unbound control and writing it to the MySQL database in an update-able view would be great. I have not looked at all of your Base videos to see if you have addresses this. I use a view for some things because I have a multiuser mysql database and you can set individual permissions on the view like a table. Thanks for your videos!

  • @shujaanjumSciedu
    @shujaanjumSciedu Před 2 lety

    great sir

  • @yohanesliong4818
    @yohanesliong4818 Před 8 měsíci

    Thank you

  • @Codertaker
    @Codertaker Před rokem

    Sean,
    What is the macro if I want to fill a text box with information according to select an option in a list? that is, dynamically changing the content of the text box with the information of the column following the one displayed in the list.
    Thanks for your help🙂

  • @chascoleman6689
    @chascoleman6689 Před 3 lety +1

    great start I'ma new to LibreBase BASIC but was Access whiz, including SQL backend and Transact processes. This means going back nearly 40 years for me to relearn this version of BASIC (not MS DAO and Access BASIC) but its similar enough its merely a re-framing of what I did so long ag o Great presentation as you presented the next task I'd set myself to learn, ie, navigation button programming.
    About those 'built in' functions, are they listed online somewhere? I will buy the book (today) as its technical detail is exactly what I have been looking for, but a quick of regular functions (like NEXT and PREVIOUS) would be very useful. thanks for your video

    • @BusinessProgrammer
      @BusinessProgrammer  Před 3 lety

      Hi Chas
      If you look at my description, Two functions are listed near the bottom of it, also for simple record navigation there are some built in button "Actions" that don't require code available on the properties window for the button. I'm aiming to post an article on this in businessprogrammer.com and a video on my channel soon, but the kids are "off school" right now :-).

  • @yovaninuno7416
    @yovaninuno7416 Před 3 lety +1

    Hi Sean Johnson, thank you very much for creating this video. I am a beginner in coding and in libreoffice base. In this video I did not understand the syntax of the code you have pasted, which you have said you were going to explain it in detail. I would like to create a macro for a button in a form. What i want this macro to do, is that the user select info from a combo box (drop down menu) and once the user has selected the info, the user must click in a button, which must send the data into a specific table. In order to do so i need a macro. In sumarize I need a button that saves the info from the form into a specific table. In order to do so, i need to create a macro in a button. I would really appreciate if you could help me out, thank you in advanced.

    • @kevinpeters1780
      @kevinpeters1780 Před 5 měsíci

      Hi Did you find the answers you were looking for ?

  • @AtlantaTerry
    @AtlantaTerry Před 4 lety +1

    Back in the '80s, I used to be a database programmer and among other things, wrote a custom office management program for a doctor who owned several weight loss clinics. Therefore, it is with interest that I would like to know what is going on with LibreOffice Base.
    M. Johnson, may I make one suggestion before you start creating a series of tutorials?
    Please number them: (text) 01, (text) 02, (text) 03, etc. That way people can more easily view them or review them in order.
    Thank you.
    Terry Thomas
    PC Tech Support
    Atlanta, Georgia USA

    • @BusinessProgrammer
      @BusinessProgrammer  Před 4 lety +2

      Hi Terry, thanks for the comment and suggestion.
      Yes I will implement what you suggested, but I don't need to text number them, I can use playlists. For Example, this is a playlist for all my LibreOffice videos
      czcams.com/video/k6XUpvYwuPg/video.html each video appears to the right of the video screen in the order that I want, therefore I'll be able to create one for LibreOffice base and include a link to it in the description of each video.
      I think this will give you what you're suggesting.

  • @chascoleman6689
    @chascoleman6689 Před 3 lety

    Could you tell me the Object method, similar to obj.next and obj.previous that will add a record? Sure will help in my data entry form I'm building. I tried obj.addnew (access version) and the interpreter kicked it out.

    • @BusinessProgrammer
      @BusinessProgrammer  Před 3 lety

      Chas
      You need to get a reference to the rowset object....
      Dim oRS as Object

      ' Create rowset object for table, kinda like a reordset (Note Rowset not resultset)
      LibreOffice (Open Office) Base programming book has the details on rowset (affiliate) amzn.to/35wqtuI
      set oRS = m_AppShared.getRowset("tblTags") ' Here I've used a custom function that I wrote to return the rowset object for "tblTags"
      With oRS
      .moveToInsertRow()
      .updateString(.findColumn("Field Names Goes Here"), "Field Values goes here")
      .insertRow()
      End With
      ' Custom function I've written to get the rowset....
      ' Return a rowset object for further manipulation
      Function getRowset(byval szTableName as String) as Object
      Dim oRowSet as Object
      Dim szPathFile as String

      oRowSet = createUnoService("com.sun.star.sdb.RowSet")
      szPathFile = m_SharedFunctions.getDbPathFile() ' Hardcode the path to your database here...
      With oRowSet
      .DataSourceName = szPathFile
      .CommandType = com.sun.star.sdb.CommandType.TABLE
      .Command = szTableName
      .execute()
      End With
      getRowset = oRowset
      End Function
      Hope this helps Chas, I believe you bought the book so that should be useful..

    • @chascoleman6689
      @chascoleman6689 Před 3 lety

      @@BusinessProgrammer got it, bulky but clean in its own way. Thanks for taking time out from flogging the crew while they're home amusing pops. Much appreciated. and ya, that was me who bought the book, gotta have documentation on the shelf.

  • @erickruhcardozo
    @erickruhcardozo Před 10 měsíci

    Can I create a form on the fly with code?
    I mean, suppose we want to get a random number of product's name and quantity. How could we create controls in the form, and then get these product names and their quantities?

    • @BusinessProgrammer
      @BusinessProgrammer  Před 10 měsíci +1

      I've never created a form on the fly and don't believe it's possible at the moment. The way that you'd display a random number of products on your form is to use the grid (table) control and populate that from code or by linking it to a table (say a table that exists just for these random products).
      Use code to populate that table and then use code to refresh the form and you're off to the races.

  • @emmadkareem5247
    @emmadkareem5247 Před 3 lety

    Thanks for the good video. I want to know if Base can be used by multiple users or not. Also is it prone to corruption like the famous other one or not - Thanks.

    • @BusinessProgrammer
      @BusinessProgrammer  Před 3 lety +1

      Multiple users is not something that I’ve tested.
      It also depends on what you mean by multiple users do you mean at the same time?
      Base can connect to MySQL which is also free and that would be a better solution for a multi user scenario. You could have base, web and dare I say Excel front ends to the same MySQL database.
      In terms of reliability of base best practice is to split the base database. Look up my video on that in my base playlist.

    • @emmadkareem5247
      @emmadkareem5247 Před 3 lety

      @@BusinessProgrammer Yes, I meant multiple users for the same database at the same time. MySQL can handle multiple users, you are correct. Thanks for the quick reply.

    • @chascoleman6689
      @chascoleman6689 Před 3 lety

      @@BusinessProgrammer absolutely right and you can also remote the MYSql database to a server you 'rent' on the web. Most web services offer MYSQL databases and storage for a small fee. Of course you need to learn enough about MYSql to secure its data and the users but that is available online and not hard to do. At a minimum you'd alter the defaults, like the PORT number as well as eliminate the 'no name' MYsql user and make sure your root and any users have a password. Linking up to MYSql with JDBC is fairly easy, just copy in the relevant files it needs (but most web services probably already have them installed). MYSql will handle multiple users 'out of the box' as it runs under Linix which is a multi-user server/operating system.

    • @achimbenoit9467
      @achimbenoit9467 Před rokem

      Everything depends on the DB you use….

    • @emmadkareem5247
      @emmadkareem5247 Před rokem

      @@BusinessProgrammer Thanks.

  • @bittertruth27
    @bittertruth27 Před 3 lety +2

    I dont understand the difference, what is need of macro, this type of events given in property .....why to code...plz help me here

    • @BusinessProgrammer
      @BusinessProgrammer  Před 3 lety +1

      I think you need a more specific question

    • @bittertruth27
      @bittertruth27 Před 3 lety

      @@BusinessProgrammer i am unable to compare that if options are already availabe in properity, why to create it by using macro...

    • @bittertruth27
      @bittertruth27 Před 3 lety

      @@BusinessProgrammer the reason i am asking , these days i am creating data base/CRM , so its good to know all aspects to use it properly...

  • @2jvsinsurance770
    @2jvsinsurance770 Před rokem

    Hi, Mr Johnson, I had create a project in MS Access, and It contain Login, Main menu, reports and complex Forms, and I did it with Mysql database. I just I'm dreaming with migrate MSAccess to Base and make it executable...Do you think can be posible?, or is waste of time!...Thanks for your Video

    • @BusinessProgrammer
      @BusinessProgrammer  Před rokem

      Am I only dreaming ? (Bangles reference 😉) no you’re not.
      I intend on creating some videos talking about MySQL.
      What you need to do is make as much of the MySQL functionality be in MySQL stored procedure’s (that would be ideal-not necessary though ) then you can easily migrate your db to many platforms.
      When I say migrate I mean keep MySQL as your db. But you can connect to it from Access, base. Python, Excel, C# etc.

  • @MdBadol-gn2pv
    @MdBadol-gn2pv Před 2 lety

    How to create push button in macro

  • @nasigoreng553
    @nasigoreng553 Před 3 lety

    Can you recommend a video tutorial on once I have created a form sub form relationship system on how to add and delete and edit records my sub form does not auto increment an ID field which i needs to be automatic.
    Still feel like baby at this atm.
    Come up with an error Duplicate Entry '0' for key 'tblLines.PRIMARY'
    Thanks in advance

    • @BusinessProgrammer
      @BusinessProgrammer  Před 3 lety

      Hey Nasi
      Go through the following playlist
      All my LibreOffice Base videos are organised here, I cover AutoIncrement in a number of them. (You need to specify autoincrement in the table that the subform references).
      Get on my email newsletter (businessprogrammer.com) and then you can reply and ask questions.
      If you go through that, you'll get a pretty good idea.
      czcams.com/video/k6XUpvYwuPg/video.html

    • @nasigoreng553
      @nasigoreng553 Před 3 lety

      @@BusinessProgrammer Thanks for the reply we have come along way since we last posted.
      We are struggling now with stand alone forms and pulling reports from the database.
      We have attached to MySQL backend but it seems so rediculous to me that a libreoffice database cannot be configured to restrict the end user from fiddling with the database main editor window.
      Access seems to have user permissions and access control features.
      Libre office base has what seems to be a duct taping idea of stand alone forms and macros or other things and the documentation on covering this is hopeless.
      Forums are convoluted and some say silly things like trust your users.
      Umm yehh no im not rolling out a libreoffice database if I cannot restrict the user properly so as they dont inadvertantly mess with tables and queries and report settings.
      Frustrating some.
      We have hit the wall for now. not sure where to go from here.
      Microsoft platforms are not possible.