Results 1 to 3 of 3

Thread: [RESOLVED] Populating datagrid from a listbox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2006
    Posts
    449

    Resolved [RESOLVED] Populating datagrid from a listbox

    Hello guys,

    I am trying to populate my datagrid from a selection from a listbox, but instead of getting one row of info or rows, I am getting one column from the database.

    Here is my code:

    Code:
    Private Sub lstRadioSerials_Click()
        If lstRadioSerials.ListIndex < -1 Then
            strRadioSerialResults = lstRadioSerials.List(lstRadioSerials.ListIndex)
            
            strSQL = "SELECT RadioInfo.SERIAL_NO,RadioInfo.COC_ID,RadioInfo.MFG,RadioInfo.BATTS_ISSUED,RadioInfo.DateIssued," _
            & "RadioInfo.ExpReturnDate,RadioInfo.ReturnDate,RadioInfo.ENTITY,RadioInfo.Phone,RadioInfo.RecvdBy,RadioInfo.CNTY_ID," _
            & "RadioInfo.MARCS_ID,RadioInfo.DEL_ID,RadioInfo.MODEL_NO,RadioInfo.MODEL_NAME,RadioInfo.Comments" _
            & "FROM RadioInfo WHERE RadioInfo.SERIAL_NO = '" & strRadioSerialResults & "'"
            rs.Close
            rs.CursorLocation = adUseClient
            rs.Open strSQL, DBConn, adOpenDynamic, adLockOptimistic
            
        End If
        
        Set Me.dgStandardQuery.DataSource = rs
    End Sub
    I know it something simple that I am missing, but I cant find what it is.

    Any help would be appreciated.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Populating datagrid from a listbox

    The IF statement is incorrect. Check if ListIndex is greater than -1 not less than.

    Actually that statement isn't needed because ListIndex will always be > -1 in the Click event.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2006
    Posts
    449

    Re: Populating datagrid from a listbox

    MAN!, I cant believe I missed that.

    I was looking everywhere else and didnt even look at that.

    Thanks so much Bruce!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width