F
FlyBoy
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). If I only have the ImpactedProject
field in the tblImpactedProjects, it works fine. If I have omre than one
field in the table, it errors out.
The main entry form frmImpactEntry is bound to tblImpacts. This is the code
I'm trying to use:
Private Sub lboxImpactedProject_LostFocus()
Dim rst As Recordset
Dim strItems As String
Dim strItems2 As String
Dim LstItem As String
Dim intCurrentRow As Integer
Set rst = CurrentDb().OpenRecordset("ImpactedProject")
' Get the list box selections
For intCurrentRow = 0 To lboxImpactedProject.ListCount - 1
'Is selected?
If lboxImpactedProject.Selected(intCurrentRow) Then
'Get value
LstItem = lboxImpactedProject.Column(0, intCurrentRow)
'Add to Table
rst.AddNew
rst("ImpactedProject") = LstItem
rst.Update
'Build list for msgbox
'strItems = strItems & LstItem & vbCrLf
End If
Next intCurrentRow
'MsgBox " You Have Selected " & vbCrLf & strItems & vbCrLf & "Open the
ListSelectResults table"
rst.Close
End Sub
Thanks in Advance
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). If I only have the ImpactedProject
field in the tblImpactedProjects, it works fine. If I have omre than one
field in the table, it errors out.
The main entry form frmImpactEntry is bound to tblImpacts. This is the code
I'm trying to use:
Private Sub lboxImpactedProject_LostFocus()
Dim rst As Recordset
Dim strItems As String
Dim strItems2 As String
Dim LstItem As String
Dim intCurrentRow As Integer
Set rst = CurrentDb().OpenRecordset("ImpactedProject")
' Get the list box selections
For intCurrentRow = 0 To lboxImpactedProject.ListCount - 1
'Is selected?
If lboxImpactedProject.Selected(intCurrentRow) Then
'Get value
LstItem = lboxImpactedProject.Column(0, intCurrentRow)
'Add to Table
rst.AddNew
rst("ImpactedProject") = LstItem
rst.Update
'Build list for msgbox
'strItems = strItems & LstItem & vbCrLf
End If
Next intCurrentRow
'MsgBox " You Have Selected " & vbCrLf & strItems & vbCrLf & "Open the
ListSelectResults table"
rst.Close
End Sub
Thanks in Advance