Link to home
Start Free TrialLog in
Avatar of D J
D JFlag for United States of America

asked on

MS Access Why do I need the ID in my list box for my code to work?

If I don't have the DRAWINGSID in my list box - row source - query builder in the 1st position the code below will not execute.
How do I get this function to work without displaying the DRAWINGSID in my list box?

Private Sub Command4_Click()
On Error Resume Next
Dim varList0 As Variant, varList2 As Variant
Dim strSQL As String


For Each varList0 In Me.List0.ItemsSelected

    For Each varList2 In Me.List2.ItemsSelected

        strSQL = "INSERT INTO tbl_HullJoin (CRAFTSID, DRAWINGSID) " _
               & "Values (" & Me.List0.ItemData(varList0) & ", " _
                            & Me.List2.ItemData(varList2) & ")"
        CurrentDb.Execute strSQL, dbFailOnError

    Next varList2

Next varList0




End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Anders Ebro (Microsoft MVP)
Anders Ebro (Microsoft MVP)
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of D J

ASKER

Thanks Anders!