Hi, I have listbox with student names.
I want to add a record to a table including the listbox's non visible items as well as the student's name
I want to add a record to a table including the listbox's non visible items as well as the student's name
VBA Code:
Private Sub btn_Create_Click()
''Dim strSQL As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim ctl As Control
Dim varItem As Variant
Set db = CurrentDb()
Set rs = db.OpenRecordset("Tbl_placements", dbOpenDynaset, dbAppendOnly)
'add selected value(s) to table
Set ctl = Me.lstSecond
For Each varItem In ctl.ItemsSelected
rs.AddNew
rs!studentID = ctl.ItemData(varItem)
rs!EmployeeID = [COLOR=rgb(226, 80, 65)]**SECOND COLUMN OF LIST BOX**[/COLOR]
rs!TradingAs = cbo_provider
rs!StartDate = txt_startdate
rs!EndDate = txt_enddate
rs.Update
Next varItem