Link to home
Start Free TrialLog in
Avatar of Graff
Graff

asked on

Listview not displaying results.

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.
Avatar of Dabas
Dabas
Flag of Australia image

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
Avatar of Graff
Graff

ASKER

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.
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.
Avatar of Graff

ASKER

I have an on error goto errorhandling and then it prints off the error in the form of a message box.
Source?
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
Avatar of Graff

ASKER

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
"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
"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
make sure your key contains a non-number character!
"005" is unacceptable while "_005" or "005_" is
"005" is unacceptable while "_005" or "005_" is
"005" is unacceptable while "_005" or "005_" is
uhhh
Avatar of Graff

ASKER

"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.
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.
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?
Avatar of Graff

ASKER

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.
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
Avatar of Graff

ASKER

They do have, what as far as I can tell, is the latest Mscomctl.ocx control on the computers.
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?

Avatar of Graff

ASKER

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.
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!
Avatar of Graff

ASKER

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
hmmm. Maybe its very stupid to ask, but just in case:

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

Dabas
Avatar of Graff

ASKER

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...
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
Avatar of DanRollins
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
ASKER CERTIFIED SOLUTION
Avatar of YensidMod
YensidMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial