VBA Combobox data from MariaDB

Shadowshiroy

New Member
Joined
Jul 18, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I am trying to display the data of a column in my MariaDB server into a userform in Excel but I cannot assign properly the values to the Combobox. I would really appreciate any type of help :)

VBA Code:
Private Sub ComboBox1_Change()

    Dim con As ADODB.Connection
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Set con = New ADODB.Connection
    con.Open "DRIVER={MariaDB ODBC 3.1 Driver};SERVER=10.5.17.100;PORT=XX;DATABASE=XX;UID=XX;PWD=XX;"
    Set tipus = con.Execute("SELECT tipusprojecte FROM tipusprojecte;")
    con.Execute Sql
    rs.Open Sql, con
    ComboBox1.DataSource.CopyFromRecordset rs
    rs.Close
    con.Close
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Do you actually have any records in the recordset?

Can you process the recordset record by record and add them into the combobox?
 
Upvote 0

Forum statistics

Threads
1,215,093
Messages
6,123,067
Members
449,090
Latest member
fragment

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top