Update table using Listbox

F

Fysh1

I also got the listbox to update the table. However, I
only seem to be able to do this if I don't have it on
Multiselect. Otherwise I keep getting a null value and it
won't be accepted in the table. Can anyone help in
solving this problem? I looked at ItemSelected, ItemData,
Loop, and everything in between.

-----Original Message-----
-----Original Message-----
Is there a way to input data into a different table from
selecting items from a combobox or listbox? The combobox
and listbox items are from a different table. Any help
would be appreciated. I have been looking all over the
place, but can't really find the info I am seeking.

OK folks I got the combobox to update the record, but for
some reason the listbox is still not updating it. It
keeps giving a null value in the record. Here is what I
came up with. Any ideas?

Dim ctlSource As Control
Dim ctlSource2 As Control
Dim strItems As String
Dim intCurrentRow As Integer
Dim dbs As Database
Dim rst As Recordset

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblClinicType")
rst.AddNew
Set ctlSource = Me.List1
Set ctlSource2 = Me.Clinic
rst![ClinicID] = ctlSource2
rst![TypeID] = ctlSource

For intCurrentRow = 0 To ctlSource.ListCount - 1
If ctlSource.Selected(intCurrentRow) Then
strItems = strItems & ctlSource.Column(0, _
intCurrentRow) & ";"
End If
Next intCurrentRow
rst.Update
rst.Close
dbs.Close
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top