?
Solved

Listview not displaying results.

Posted on 2003-03-04
29
Medium Priority
?
315 Views
Last Modified: 2012-05-04
I have a listview that lists off the registered contacts for a certain event. On my computer (winxp), my friends laptop (xp), his computer(xp), my clients laptop (xp), my school's computers (win2000) the program runs as expected.

However on my client's assistants' computers they don't work (WinNT and Win2000). It does not generate an error but it seems to just run over the code as if it didn't exist.
0
Comment
Question by:Graff
[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
  • 12
  • 9
  • 5
  • +3
29 Comments
 
LVL 27

Expert Comment

by:Dabas
ID: 8066873
Looks to me as a failed installation.
I do not think it is OS related, since you did install it on another Win2000.

Try reinstalling your application on the culprit computer. Sometimes an installation requires a reboot, and then setup.exe has to be run again, which is a step that is easily omitted.

Dabas
0
 
LVL 1

Author Comment

by:Graff
ID: 8066944
I should also mention the fact that every other listview seems to be working as expected. Only difference as far as I can tell is that this one has checkboxes.
0
 

Expert Comment

by:selectgt
ID: 8066978
Actually, ensure you use "On Error Resume Next"

For one reason or another when you try to access some of the properties or methods of a control's child units (in this case, an item) it can actually cause your program's execution stack to just quit.  So, in the event that you tried to access an item's property that doesn't exist, it may cause your code to throw an exception...and since it's unhandled it will just exit the function which would exactly explain your "It does not generate an error but it seems to just run over the code as if it didn't exist."


If you add "On Error Resume Next" and write proper error trapping code where you might access these missing items then this will fix your ghost code problem.

Hope this helps.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:Graff
ID: 8067001
I have an on error goto errorhandling and then it prints off the error in the form of a message box.
0
 
LVL 5

Expert Comment

by:JMoon5FTM
ID: 8067032
Source?
0
 

Expert Comment

by:selectgt
ID: 8067041
Also, be sure that if you're using an object to not change your current properties..For example.

'Assuming you have lstListItems as a Listview control
'in your application with 1 subitems for the control

On Error Resume Next

Dim A$(1 to 4)
Dim itmX as listitem
Dim i as integer

A$(1)="aA"
A$(2)="bB"
A$(3)="cC"
A$(4)="bB"

For i = lbound(A$) to ubound$(a$)
 set itmx = lstListItems.additem(,,a$(i),a$(i))
 itmx.text = a$(i)
next i

|If you were to execute this code you would notice that
|Instead of 4 items you would simply just have 3 and the
|3rd item "cC" would have teh subitem read "bB" since the
|itmX object was never redefined to the new item because
|the item "bB" had already existed.

|without proper error handling i'm pretty sure this is
|an instance that would cause your "ghost code" to happen.
|If not, i'm sorry .. lol.  I wrote this off the top of my
|head into this window.

|If not that, it's some other propery..maybe the Key
|property along with some others that will definitely
|cause that error to happen.


|y the way, an easy way to fix that problem up there
|would be to add

If NOT Err then
0
 
LVL 1

Author Comment

by:Graff
ID: 8067053
Private Sub cboEventList_Click()

    'Add error handling routines
    On Error GoTo Err_cboEventList_Click

    Dim evID As String
    Dim IDPos As Integer
    Dim Query As String
    Dim lngUserCount As Long
    Dim itmX As ListItem
    IDPos = InStrRev(cboEventList.Text, "-")
    evID = Mid(cboEventList.Text, IDPos + 2)
    Query = "SELECT u.UserID, u.First_Name, u.Last_Name, c.Name, c.CompanyID, s.Type, r.Speaker, e.Price, r.P_Method, UNIX_TIMESTAMP(r.Date_Registered) Date_Registered, r.Attended FROM User u, Company c, Status s, Registration r, Event e WHERE "
    Query = Query & "e.EventID = " & evID & " AND r.EventID = e.EventID AND u.UserID = r.UserID AND c.CompanyID = u.CompanyID AND s.StatusID = c.StatusID "
    Query = Query & "ORDER BY s.StatusID, u.Last_Name"
    rs.Open Query, conn
        frmMain.lvRegContacts.ListItems.Clear
        Do Until rs.EOF
           
            Set itmX = frmMain.lvRegContacts.ListItems.Add(, , Format(rs!UserID, "0000"))
            If rs!Attended = 1 Then
                itmX.Checked = True
            End If
            itmX.SubItems(1) = rs!Last_Name
            itmX.SubItems(2) = rs!First_Name
            itmX.SubItems(3) = rs!Name
           
            If rs!speaker = 1 Then                      'Speaker takes precedence over member
                itmX.SubItems(4) = "1 - Speaker"
                itmX.SubItems(5) = "N/C"
                itmX.SubItems(6) = "Free"
            Else
                Select Case rs!Type
                    Case "Member"                       'Member takes precedence over Non-member
                        itmX.SubItems(4) = "2 - " & rs!Type
                        Query = "SELECT count(u.UserID) cntUsers " & _
                        "FROM User u, Company c, Registration r, Event e " & _
                        "WHERE c.CompanyID = u.CompanyID AND " & _
                              "c.CompanyID = " & rs!CompanyID & " AND " & _
                              "u.UserID = r.UserID AND " & _
                              "r.EventId = e.EventID AND " & _
                              "r.EventID = '" & evID & "' AND " & _
                              "r.Speaker != '1' AND " & _
                              "r.P_Method != 'N/C' AND " & _
                              "c.StatusID = '1' AND " & _
                              "UNIX_TIMESTAMP(r.Date_Registered) < '" & rs!Date_Registered & "'"
                                     
                        'Query = "SELECT count(u.UserID) cntUsers FROM User u, Company c, Registration r, Event e WHERE c.CompanyID = u.CompanyID AND u.UserID = r.UserID AND r.EventId = e.EventID AND r.EventID = '" & evID & "' AND r.Speaker != '1' AND r.P_Method != 'N/C' AND c.StatusID = '1' AND UNIX_TIMESTAMP(r.Date_Registered) < '" & rs!Date_Registered & "'"
                        Debug.Print Query
                            'Query = "SELECT count(u.UserID) cntUsers FROM User u, Registration r, Event e, Company c WHERE " & _
        '                     "c.CompanyID = u.CompanyID AND u.UserID = r.UserID AND e.EventID = r.EventID AND " & _
        '                     "r.Speaker <> 1 AND r.P_Method <> 'N/C' AND c.StatusID = 1 AND e.EventID = " & evID & " AND r.Date_Registered < '" & rs!Date_Registered & "'"
                        rs2.Open Query, conn
                        If Not rs2.EOF Then
                           
                           
                            Select Case rs2!cntUsers
                                Case 0:                                 'If the member is the first to register it's free
                                    itmX.SubItems(6) = "Free"
                                    itmX.SubItems(5) = "N/C"
                                Case 1:                                 'If there is one member registered before them it's half price
                                    itmX.SubItems(6) = rs!Price / 2
                                    itmX.SubItems(5) = rs!P_Method
                                Case Else                               'For all other members and non-members it's full price
                                    itmX.SubItems(6) = rs!Price
                                    itmX.SubItems(5) = rs!P_Method
                            End Select
                        End If
                        rs2.Close
                    Case "Non-Member"
                        itmX.SubItems(4) = "3 - " & rs!Type
                        itmX.SubItems(5) = rs!P_Method
                        If rs!P_Method = "N/C" Then
                            itmX.SubItems(6) = "FREE"
                        Else
                            itmX.SubItems(6) = rs!Price
                        End If
                       
                        itmX.SubItems(5) = rs!P_Method
                End Select
               
               
            End If

            rs.MoveNext
        Loop
    rs.Close

'End of main Sub
Exit Sub
'-------------------------------------------------------------------------------
 'Error handler
'-------------------------------------------------------------------------------
Err_cboEventList_Click:
If rs.State = adStateOpen Then
        rs.Close
End If

    'Create error message
   
    ErrorMessage1 = "" & "An unexpected error has occurred" & vbCrLf & Err.Description & vbCrLf & "(error " & CStr(Err.Number) & ")" & vbCrLf & "In module: " & Me.Name & vbCrLf & "Sub: cboEventList_Click"

    'Clear error
    Err.Clear

    'Display error message
    frmReport.Show vbModal

    'Exit Sub
    Exit Sub
End Sub
0
 

Expert Comment

by:selectgt
ID: 8067095
"I have an on error goto errorhandling and then it prints off the error in the form of a message box."

Ahh i see.  Then you're problem lies within the item itself.  An easy way to fix all of your problems would be simply to go through and find the part that is causing yout he headache and simply make sure the item exists before your access it's propeties.

Here's an example i whipped up just now.


'Assumes you have the following
'  1 Form
'  1 ListView control named "ListView1"
'  1 Text box
'  1 Command Button

Private Sub Command1_Click()
MsgBox doesItemExist(ListView1, Text1.Text)
End Sub

Private Sub Form_Load()
Dim itmX As ListItem
Set itmX = ListView1.ListItems.Add(, "hi", "hi")
End Sub

Function doesItemExist(lst As ListView, theKey$) As Boolean
 Dim i As Integer
 For i = 1 To lst.ListItems.Count
  If lst.ListItems(i).Key = theKey$ Then
   doesItemExist = True
   Exit Function

  End If

 Next i

 doesItemExist = False

End Function
0
 

Expert Comment

by:selectgt
ID: 8067133
"I have an on error goto errorhandling and then it prints off the error in the form of a message box."

Ahh i see.  Then you're problem lies within the item itself.  An easy way to fix all of your problems would be simply to go through and find the part that is causing yout he headache and simply make sure the item exists before your access it's propeties.

Here's an example i whipped up just now.


'Assumes you have the following
'  1 Form
'  1 ListView control named "ListView1"
'  1 Text box
'  1 Command Button

Private Sub Command1_Click()
MsgBox doesItemExist(ListView1, Text1.Text)
End Sub

Private Sub Form_Load()
Dim itmX As ListItem
Set itmX = ListView1.ListItems.Add(, "hi", "hi")
End Sub

Function doesItemExist(lst As ListView, theKey$) As Boolean
 Dim i As Integer
 For i = 1 To lst.ListItems.Count
  If lst.ListItems(i).Key = theKey$ Then
   doesItemExist = True
   Exit Function

  End If

 Next i

 doesItemExist = False

End Function
0
 

Expert Comment

by:selectgt
ID: 8067138
make sure your key contains a non-number character!
0
 

Expert Comment

by:selectgt
ID: 8067148
"005" is unacceptable while "_005" or "005_" is
0
 

Expert Comment

by:selectgt
ID: 8067159
"005" is unacceptable while "_005" or "005_" is
0
 

Expert Comment

by:selectgt
ID: 8067171
"005" is unacceptable while "_005" or "005_" is
0
 

Expert Comment

by:selectgt
ID: 8067174
uhhh
0
 
LVL 1

Author Comment

by:Graff
ID: 8067188
"make sure your key contains a non-number character! "
 
"'005' is unacceptable while '_005' or '005_' is "

If that were the case selectqt why would the listview work on all computers we tested but the two mentioned.
0
 

Expert Comment

by:selectgt
ID: 8067250
I have no idea.  There would be absolutely no practical reason for anyone to expect me to know or not know whether you are using 1 central database or multiple databases.  I'm simply trying to help you.  I can't read minds.
0
 

Expert Comment

by:selectgt
ID: 8067260
What i mean by that, is that some of the databases could have valid Key identifiers while the machine that wasn't working may have had invalid Key identifiers.

How would you expect me to know otherwise?
0
 
LVL 1

Author Comment

by:Graff
ID: 8067314
The matter of the key containg non numerical characters has nothing to do with the database.

There is only 1 database, but if there were multiple databases it would stand to reason that they all contain exactly the same tables and fields within them.
0
 
LVL 27

Expert Comment

by:Dabas
ID: 8067434
Seems we got sidetracked.

Lets go back to the problem in question:

Your program works on some computers and not on others.
This means that the problem is not the underlying data, or something to be solved using Resume Next.

The clue to solving the problem is where you mention that the listview that has checkboxes creates the problem.

My guess is that the problem here is the listview version that is registered in the System folder.

Does the culprit computer have the correct version of MSCOMCTL.OCX installed?

This is Microsoft Common Controls 6.0

Microsoft Common Controls 5.0 (Comctl32.OCX) did not support checkboxes.

Dabas
0
 
LVL 1

Author Comment

by:Graff
ID: 8067441
They do have, what as far as I can tell, is the latest Mscomctl.ocx control on the computers.
0
 
LVL 27

Expert Comment

by:Dabas
ID: 8067564
I am sure that it IS Mscomclt.ocx related.
What can you lose by just physically deleting this file and reinstalling it to prove me wrong?

0
 
LVL 1

Author Comment

by:Graff
ID: 8067684
I'm fairly certain it is not the mscomctl.ocx, I will do as you ask tomorrow when we can get back onto the client's computers tomorrow.

However, I would like to know if anyone has any contingency plans.

I have heard from other sources that it could also be the MDAC drivers which I will also be trying.
0
 

Expert Comment

by:selectgt
ID: 8070497
good luck to you.  i'm nearly positive you'll find it's something to do with you accessing a property (probably a checkbox property) on an item that doesn't exist.  The sudden quit of a subroutine due to this is quite common and extra care should be taken in this area.

Hope you find what's wrong and i'm quite anxious to hear the solution!
0
 
LVL 1

Author Comment

by:Graff
ID: 8085697
It's not the mscomctl.ocx
It's not the mdac drivers
It COULD be that it's not 2000 SP3 (we're getting their IT department to upgrade them to SP3, hopefully it will be done tomorrow)

It has nothing to do with the checkbox properties (I tested a version without check boxes). It seems to die somewhere in this chunk of code:

    rs.Open Query, conn
       frmMain.lvRegContacts.ListItems.Clear
       Do Until rs.EOF
           
           Set itmX = frmMain.lvRegContacts.ListItems.Add(, , Format(rs!UserID, "0000"))


I place message boxes just before and some after this, none of the one's after this were triggered (I forgot to put on after the rs.close though so I know it's not executing anything inside the rs.open -> rs.close
0
 
LVL 27

Expert Comment

by:Dabas
ID: 8085749
hmmm. Maybe its very stupid to ask, but just in case:

You do have a rs.MoveNext statement somewhere inside the Do?

Dabas
0
 
LVL 1

Author Comment

by:Graff
ID: 8085988
Yes (I posted the code in this question, it's about halfway up the page) regardless I had message boxes inside the loop that should appear if the code was getting executed (even if it were the same record set to begin with). Don't forget the fact that this is code that works perfectly on a bunch of other machines.


I'm almost 100% sure that it's operating system related... for some reason my code works on Win2000 Sp3 and XP but nothing before that...
0
 
LVL 27

Expert Comment

by:Dabas
ID: 8086041
Graff:
(after reviewing your code, and apologies for not having done so before)

Please compare the memory capability of the culprit computers with the ones where the program works.

Just possible that the error message you are not receiving is an "Out of memory" one.

In that case the program would not have enough memory to open yet another form to show you the error and would behave the way you are describing.

Just in case, try to replace the callto frmReport with a simple MsgBox Err.Description.

I know it is a shot in the dark, but that would be my next step if I were in your position

Dabas
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9046825
Hi Graff,
It appears that you have forgotten to close this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.
    *** apparently no resolution, but some PAQworthy comments

Graff, Please DO NOT accept THIS comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9151030
Question is PAQ'd and points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

764 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