|
-
Feb 24th, 2009, 06:19 PM
#1
Thread Starter
Hyperactive Member
[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.
-
Feb 24th, 2009, 07:01 PM
#2
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.
-
Feb 24th, 2009, 07:36 PM
#3
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|