Multi-Select List Box

G

Guest

I've read all the posts, went to all the suggested sites, and tried all the
sample code. I know I'm dense, but I still can't get a multiselct list box to
store values in the table I want.

Using A2003 on XPPro, I have one table, tblImpacts linked 1toMany to another
table, tblImpactedProjects via the tblImpacts PK, EntryID (autonumber) to
tblImpactedProjects EntryID (number).

The main entry form frmImpactEntry is bound to tblImpacts. This is the code
I'm trying to use:

Dim rst As Recordset
Dim strItems As String
Dim strItems2 As String
Dim LstItem As String
Dim intCurrentRow As Integer


Set rst = CurrentDb().OpenRecordset("ImpactedProjects")
' Get the list box selections
For intCurrentRow = 0 To List0.ListCount - 1
'Is selected?
If List0.Selected(intCurrentRow) Then
'Get value
LstItem = List0.Column(0, intCurrentRow)
'Add to Table
rst.AddNew
rst("ImpactedProjects") = LstItem
rst.Update
'Build list for msgbox
'strItems = strItems & LstItem & vbCrLf
'Build list for 2nd box
'strItems2 = strItems2 & LstItem & ";"
End If
Next intCurrentRow
rst.Close

Thanks in Advance
 
D

Dirk Goldgar

FlyBoy said:
I've read all the posts, went to all the suggested sites, and tried
all the sample code. I know I'm dense, but I still can't get a
multiselct list box to store values in the table I want.

Using A2003 on XPPro, I have one table, tblImpacts linked 1toMany to
another table, tblImpactedProjects via the tblImpacts PK, EntryID
(autonumber) to tblImpactedProjects EntryID (number).

The main entry form frmImpactEntry is bound to tblImpacts. This is
the code I'm trying to use:

Dim rst As Recordset
Dim strItems As String
Dim strItems2 As String
Dim LstItem As String
Dim intCurrentRow As Integer


Set rst = CurrentDb().OpenRecordset("ImpactedProjects")
' Get the list box selections
For intCurrentRow = 0 To List0.ListCount - 1
'Is selected?
If List0.Selected(intCurrentRow) Then
'Get value
LstItem = List0.Column(0, intCurrentRow)
'Add to Table
rst.AddNew
rst("ImpactedProjects") = LstItem
rst.Update
'Build list for msgbox
'strItems = strItems & LstItem & vbCrLf
'Build list for 2nd box
'strItems2 = strItems2 & LstItem & ";"
End If
Next intCurrentRow
rst.Close

Thanks in Advance

These lines ...
Set rst = CurrentDb().OpenRecordset("ImpactedProjects") ....
rst("ImpactedProjects") = LstItem

.... imply that your table, named "ImpactedProjects", also has a field
named "ImpactedProjects". Is this really true?
 
G

Guest

Thanks for your replies. I've used a different solution.

Thanks again, and again, sorry about the duplicate post.
 

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