Listbox Selection Problem

Discussion in 'AutoCAD' started by SirLevAris, Jul 8, 2003.

  1. SirLevAris

    SirLevAris Guest

    I have routine that gets a list from an Access database depending on a certain value existing in one of the fields. This part works.

    I am now trying to take what is selected and run my insert routine based on the selected text in listbox (which is mutli-extended). Here is the code for that section:

    Dim noteCount As Integer
        Dim noteID As String
        Dim noteInfo As ADODB.Recordset

    For noteCount = 1 To NoteForm.NoteList.ListCount
            If NoteForm.NoteList.Selected(noteCount) = True Then
                'open CAD database
                dbCreateConnections
                dbOpenDatabase

    'seet SQL connection
                mcmdLocal.CommandType = adCmdText
                mcmdLocal.CommandText = "SELECT * FROM [Drawing Notes] WHERE " _
                                        & "Abbr = '" & NoteList.Text & "'"

    'run query and store in recordset
                Set noteInfo = mcmdLocal.Execute

    noteID = noteInfo.Fields("Name")

    'close CAD database
                dbclosedatabase

    'insert note
                insertIdents noteID
            End If
        Next noteCount



    I use Microsoft ActiveX Data Objects 2.5 Library for the recordset handling and the insertIdents routine works in another module (which is referenced in this one). The problem is at the SQL line... I need to have the text AS IT APPEARS in the listbox for that line to work. How do I get that text?
     
    SirLevAris, Jul 8, 2003
    #1
  2. SirLevAris

    Tom Craft Guest

    listbox.text
     
    Tom Craft, Jul 10, 2003
    #2
  3. SirLevAris

    Nathan Guill Guest

    My listbox has been renamed to NoteList and the .text method returns "".
    Besides, with mutiple selections, wouldn't that method give you all text in
    the listbox?

     
    Nathan Guill, Jul 10, 2003
    #3
  4. SirLevAris

    Nathan Guill Guest

    I did look.  This is the code I got out of it, but it doesn't work.  Could someone please look at my code and see where I went wrong?  (It's in the original message.)



    "wivory" <> wrote in message news:...

    Have a look in the Help at the .List property, and for multiselections also see the .Selected property.
      
    Regards
      
    Wayne Ivory
    IT Analyst Programmer
    Wespine Industries Pty Ltd
     
    Nathan Guill, Jul 14, 2003
    #4
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 (here). After that, you can post your question and our members will help you out.