Modify data source in a form

Creating and using forms
Post Reply
salrandazzo
Posts: 5
Joined: Fri Aug 30, 2013 4:15 pm

Modify data source in a form

Post by salrandazzo »

Hi folks.
I'm trying to understand how basic works with API and UNO.
Found some documentation about basic, but I really get lost with API and UNO.
My purpose is this one, so simple:
MySQL database with just one table: tbCustomers, with name, phone and address.
Then a OpenOffice base application connected with the MySQL database.
Done.
But now my purpose is:
Form connected with the only one table tbCustomers in the MySQL database.
It works, and I can see and modify data.
No need for basic macros, so far.
Now I want to make it harder. I add two text fields, not connected. One named txtPhone, other named txtAddr
When the user starts typing into one txt field, no matter what, the "modified" event should trigger a basic function that will compile a SQL string to filter records of the tbCustomers table in the form

I did it quite easy using msAccess. This was the working code:

Code: Select all

'
' This sub makes a search in the customers table for a phone number
' that contains the digits that the user inserts as a pre-selection
' into the text box TxNumTel
' 

Private Sub TxNumTel_Change()
    Dim TelNumParz As String        ' partial phone number
    Dim SQL_query As String         ' SQL quuery string
    
    TelNumParz = Me.TxNumTel.Text   ' Partial phone number from the TxNumTel text box
    
    '
	' If the partial phone number is not empty
	' I prepare a SQL query string
	' and I will assign it to the listbox RpRicercaElencoClienti
	' then I start a requery
    '

    If Not IsNull(TelNumParz) Then
        SQL_query = " Select ID,Nominativo,Indirizzo,Telefono,Note " & _
        "from Clienti where (Telefono like " & Chr$(34) & "*" & TelNumParz & "*" & Chr$(34) & ");"
        Me.RpRicercaElencoClienti.RowSource = SQL_query
        Me.RpRicercaElencoClienti.Requery
    End If


End Sub

But I can't succeed to understand how to make it with OpenOffice base + MySQL + basic
The main problem is that I can't understand how to get my information from the API/UNO documentation. I get lost.
Any hint?
Thanks a lot
Attachments
TestBasic.odb
The simple MySQL+OpenOffice Base
(17.21 KiB) Downloaded 235 times
OpenOffice 4.1.4 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Modify data source in a form

Post by Villeroy »

Install the MRI extension. It comes with a small Basic module.
Read [Tutorial] Introduction into object inspection with MRI

Bind your form control event to MyMacros>MriLib>Module1.Mri and see
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
salrandazzo
Posts: 5
Joined: Fri Aug 30, 2013 4:15 pm

Re: Modify data source in a form

Post by salrandazzo »

Thanks, I'll go on
OpenOffice 4.1.4 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Modify data source in a form

Post by Villeroy »

But first of all you should learn each and every aspect of Base forms. They are very simplistic, nevertheless flexible and powerful. Any form created by the "form wizard" does not even cover 10% of the capabilities.
If you implement some "power filtering" (search this forum) together with a most simple, event driven script which refreshes the filtered subform, then you have a filter-as-you-type form.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply