listview won't display data populated in vb6
-
This is now solved. I can walk the code through and watch the data populate but nothing other than the headings are displayed. I am not sure what is different with this compared to others that have been done and i have even compared code and they all work the same so there must be something i am over looking.
Dim nUserID As Long
Dim sToday As String
Dim sUser As String
Dim sSQL As StringDim li As ListItem Me.lvMain.ListItems.Clear 'rsUser.MoveFirst Set dbGlob = OpenDatabase(GenPath & "WORORDGB.MDB") 'Set rsCal = Nothing sToday = sDate Select Case UCase(sType) Case "ALL" 'All sSQL = "SELECT \* FROM \[Accum\] WHERE \[Type\] = 'LABOR' AND \[Closed\]= 0 AND \[WOCounter\] <> 0 ORDER BY \[Date\],\[UserID\],\[Start\],\[WOCounter\]" Set rsCal = dbGlob.OpenRecordset(sSQL) rsCal.MoveLast rsCal.MoveFirst Case "WO" 'WO Set rsCal = dbGlob.OpenRecordset("SELECT \* FROM \[Accum\] WHERE \[Type\] = 'LABOR' AND \[Closed\]= 0 AND \[WOCounter\] = " & CInt(Trim(Me.cmbWOID.Text)) & " ORDER BY \[Date\],\[UserID\],\[Start\],\[WOCounter\]") rsCal.MoveLast rsCal.MoveFirst Case "WR" 'WORKER Set rsCal = dbGlob.OpenRecordset("SELECT \* FROM \[Accum\] WHERE \[Type\] = 'LABOR' AND \[Closed\]= 0 AND \[WOCounter\] <> 0 AND \[UserID\]=" & CLng(Me.cmbuserID.Text) & " ORDER BY \[Date\],\[UserID\],\[Start\],\[WOCounter\]") rsCal.MoveLast rsCal.MoveFirst Case "WRWO" 'Worker - WO Set rsCal = dbGlob.OpenRecordset("SELECT \* FROM \[Accum\] WHERE \[Type\] = 'LABOR' AND \[Closed\]= 0 AND \[WOCounter\] = " & CInt(Trim(Me.cmbWOID.Text)) & " AND \[UserID\]=" & CLng(Me.cmbuserID.Text) & " ORDER BY \[Date\],\[UserID\],\[Start\],\[WOCounter\]") rsCal.MoveLast rsCal.MoveFirst End Select With Me.lvMain '.ListItems.Clear If rsCal.RecordCount = 0 Then Set li = .ListItems.Add(1, "ID" & rsUser.Fields("ID").Value, "Empty", , 4) Exit Sub End If For X = 1 To rsCal.RecordCount If IsNull(rsCal.Fields("UserID").Value) Then sUser = rsCal.Fields("Desc").Value Else For Y = 0 To cmbUser.ListCount - 1 If CLng(rsCal.Fields("UserID").Val
-
This is now solved. I can walk the code through and watch the data populate but nothing other than the headings are displayed. I am not sure what is different with this compared to others that have been done and i have even compared code and they all work the same so there must be something i am over looking.
Dim nUserID As Long
Dim sToday As String
Dim sUser As String
Dim sSQL As StringDim li As ListItem Me.lvMain.ListItems.Clear 'rsUser.MoveFirst Set dbGlob = OpenDatabase(GenPath & "WORORDGB.MDB") 'Set rsCal = Nothing sToday = sDate Select Case UCase(sType) Case "ALL" 'All sSQL = "SELECT \* FROM \[Accum\] WHERE \[Type\] = 'LABOR' AND \[Closed\]= 0 AND \[WOCounter\] <> 0 ORDER BY \[Date\],\[UserID\],\[Start\],\[WOCounter\]" Set rsCal = dbGlob.OpenRecordset(sSQL) rsCal.MoveLast rsCal.MoveFirst Case "WO" 'WO Set rsCal = dbGlob.OpenRecordset("SELECT \* FROM \[Accum\] WHERE \[Type\] = 'LABOR' AND \[Closed\]= 0 AND \[WOCounter\] = " & CInt(Trim(Me.cmbWOID.Text)) & " ORDER BY \[Date\],\[UserID\],\[Start\],\[WOCounter\]") rsCal.MoveLast rsCal.MoveFirst Case "WR" 'WORKER Set rsCal = dbGlob.OpenRecordset("SELECT \* FROM \[Accum\] WHERE \[Type\] = 'LABOR' AND \[Closed\]= 0 AND \[WOCounter\] <> 0 AND \[UserID\]=" & CLng(Me.cmbuserID.Text) & " ORDER BY \[Date\],\[UserID\],\[Start\],\[WOCounter\]") rsCal.MoveLast rsCal.MoveFirst Case "WRWO" 'Worker - WO Set rsCal = dbGlob.OpenRecordset("SELECT \* FROM \[Accum\] WHERE \[Type\] = 'LABOR' AND \[Closed\]= 0 AND \[WOCounter\] = " & CInt(Trim(Me.cmbWOID.Text)) & " AND \[UserID\]=" & CLng(Me.cmbuserID.Text) & " ORDER BY \[Date\],\[UserID\],\[Start\],\[WOCounter\]") rsCal.MoveLast rsCal.MoveFirst End Select With Me.lvMain '.ListItems.Clear If rsCal.RecordCount = 0 Then Set li = .ListItems.Add(1, "ID" & rsUser.Fields("ID").Value, "Empty", , 4) Exit Sub End If For X = 1 To rsCal.RecordCount If IsNull(rsCal.Fields("UserID").Value) Then sUser = rsCal.Fields("Desc").Value Else For Y = 0 To cmbUser.ListCount - 1 If CLng(rsCal.Fields("UserID").Val
Initial suggestion: divide and conquer. Is is the listview or the data? Try building your listview using other data; say, the numbers 1 to 10 and see what happens. Also, try writing the database data to a text field, a file or the console window. Enjoy you're getting data when NOT in debug mode. If they both work independently, then we can look at it again. Having said that, VB 6 is no longer supported; consider moving to .NET. There are free versions available for download (VB.NET Express).
-
Initial suggestion: divide and conquer. Is is the listview or the data? Try building your listview using other data; say, the numbers 1 to 10 and see what happens. Also, try writing the database data to a text field, a file or the console window. Enjoy you're getting data when NOT in debug mode. If they both work independently, then we can look at it again. Having said that, VB 6 is no longer supported; consider moving to .NET. There are free versions available for download (VB.NET Express).
Thanks I am sorry i thought i deleted this thread. I did resolve the problem. And yes I am migrating the complete application to newer code base using VS2013. Thanks again