Solved

Runtime error 3346 - Multi select list box

Posted on 2008-09-30
9
1,222 Views
Last Modified: 2010-04-21
I'm getting a runtime 3346 error on the following code.  Any help at debugging would be greatly appreciated.   I have a multi select list box on a form.  I'm trying to append the contents of the selection (6 columns) to my table tblOOSInventory.  

Dim strItems As String
    Dim intItem As Integer
    For intItem = 0 To List2.ListCount - 1
        If List2.Selected(intItem) Then
            strItems = strItems & List2.Column(0, intItem) & ";" & _
                                  List2.Column(1, intItem) & ";" & _
                                  List2.Column(2, intItem) & ";" & _
                                  List2.Column(3, intItem) & ";" & _
                                  List2.Column(4, intItem) & ";" & _
                                  List2.Column(5, intItem) & ";"
        End If
       
 >>>>>> Error 3346 happens here >>>>> Currentdb.Execute "Insert into tblOOSInventory(InvIssID, EmpID, IssBC, InvType, Size, ILOC) values (stritems)"
    Next intItem
0
Comment
Question by:AnneYourPointIs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 22604700
first post the data type of the following fields

InvIssID, EmpID, IssBC, InvType, Size, ILOC


0
 

Author Comment

by:AnneYourPointIs
ID: 22604734
Hello cap,

Thanks for responding.  The following are the field datatypes:

InvIssID = Number
EmpID = Number
IssBC=Text
InvType=Text
Size= Text
ILoc=Text
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 22604815

Dim strItems As String
    Dim intItem , sql

    With Me.List2
    For intItem = 0 To .ListCount - 1
        If .Selected(intItem) Then
            strItems = strItems & .Column(0, intItem) & "," & _
                                  .Column(1, intItem) & "," & _
                                Chr(39) & .Column(2, intItem) & Chr(39) & "," & _
                                Chr(39) & .Column(3, intItem) & Chr(39) & "," & _
                                Chr(39) & .Column(4, intItem) & Chr(39) & "," & _
                                Chr(39) & .Column(5, intItem) & Chr(39)

        sql = "Insert into tblOOSInventory(InvIssID, EmpID, IssBC, InvType, Size, ILOC) values (" & strItems & ")"
        currentdb.execute sql
        End If
    Next
    End With
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:AnneYourPointIs
ID: 22604892
I'm now getting a runtime error 3075 syntax error missing operator in query expression "P'597"

Dim strItems As String
    Dim intItem, sql

    With Me.List2
    For intItem = 0 To .ListCount - 1
        If .Selected(intItem) Then
            strItems = strItems & .Column(0, intItem) & "," & _
                                  .Column(1, intItem) & "," & _
                                Chr(39) & .Column(2, intItem) & Chr(39) & "," & _
                                Chr(39) & .Column(3, intItem) & Chr(39) & "," & _
                                Chr(39) & .Column(4, intItem) & Chr(39) & "," & _
                                Chr(39) & .Column(5, intItem) & Chr(39)

        sql = "Insert into tblOOSInventory(InvIssID, EmpID, IssBC, InvType, Size, ILOC) values (" & strItems & ")"
>>>> 3075 occurs here>>>>        Currentdb.Execute sql
        End If
    Next
    End With
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 22604952
what column is this coming from { "P'597" }
0
 

Author Comment

by:AnneYourPointIs
ID: 22604981
Im not sure what the "P" is but 597 is column 0, InvIssID
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 22605009
forget to clear strItems


Dim strItems As String
    Dim intItem, sql

    With Me.List2
    For intItem = 0 To .ListCount - 1
        If .Selected(intItem) Then
            strItems = strItems & .Column(0, intItem) & "," & _
                                  .Column(1, intItem) & "," & _
                                Chr(39) & .Column(2, intItem) & Chr(39) & "," & _
                                Chr(39) & .Column(3, intItem) & Chr(39) & "," & _
                                Chr(39) & .Column(4, intItem) & Chr(39) & "," & _
                                Chr(39) & .Column(5, intItem) & Chr(39)

        sql = "Insert into tblOOSInventory(InvIssID, EmpID, IssBC, InvType, Size, ILOC) values (" & strItems & ")"
 Currentdb.Execute sql
       
     strItems=""            '<<<ADD this line

        End If
    Next
    End With
0
 

Author Comment

by:AnneYourPointIs
ID: 22608536
great!  Thanks so much for your help.
0
 

Author Closing Comment

by:AnneYourPointIs
ID: 31501700
Thanks Cap!  You always come through for me.  I appreciate it a lot.  
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question