How to get the data of a Listbox to DatabaseRecord

Hi Everyone!

I have this code, with this method I can make a new record on the “Recibidas” table

Dim row As New DatabaseRecord
// ID will be updated automatically
row.Column(“XML”) = “027BB01E-E54D-473E-8616-91407405EBC3.xml”
row.Column(“RFCEmitter”) = “GHU071016HE1”
row.Column(“NameEmitter”) = “HUITEPEC GAS STATION, S.A. DE C.V.”
row.Column(“UUID”) = “027BB01E-E54D-473E-8616-91407405EBC3”

app.mDb.InsertRecord(“Recibidas”, row)

If app.mDb.Error Then
MsgBox("DB Error: " + app.mDb.ErrorMessage)
End If

But I dun know how to get the data of my “listafacturas” listbox for use it on this DatabaseRecord, and once done it, apply it on app.mDb.InsertRecord
in order tomato a new record.
Probably use a for instruction or a loop.

Ideas?
THx

Yes, that is what a For loop is for. :slight_smile:
You would also use ListBox.Cell to get values for specific cells to add to a DatabaseRecord.

[code]For lbRow As Integer = 0 To MyListBox.ListCount - 1
Dim dbRow As New DatabaseRecord

// Assign each column in the ListBox row to a specific column in the database row.
dbRow.Column(“XML”) = MyListBox.Cell(lbRow, 1) // ListBox column # containing the data for XML
dbRow.Column(“RFCEmitter”) = MyListBox.Cell(lbRow, 2) // ListBox column # containing the data for RFCEmitter
// etc.

// Save to the database
App.mDB.InsertRecord(“Recibidas”, dbRow)

// Check for errors
If App.mDB.Error Then
MsgBox(“DB Error: " + App.mDB.ErrorMessage”)
// Probably want to stop
Exit For
End If

Next[/code]