VBA error 6 overflow

DocZayus

Registered User.
Local time
Yesterday, 19:43
Joined
Jun 22, 2004
Messages
16
I was using this code to see qho is currently logged into my access project, and it worked well untill our servers changed.

I get the machine name ok, but not the user names and I get an overflow error.

I've read that IIF can be a source of overflow errors, but I have no clue.

Code:
Function fListFill(ctl As Control, varID As Variant, varRow As Variant, _
                varCol As Variant, varCode As Variant) As Variant
'Callback function to fill the multirow-multicolumn listbox
'
Dim varRet As Variant
Const TWIPS = 1440
Const COLUMN_COUNT = 2
Const ROSTER_COLUMN_COUNT = 5
Const ROSTER_ERROR_MSG = "Couldn't retrieve info from the LDB file"

    On Error GoTo ErrHandler
    Select Case varCode
 
        Case acLBInitialize
            varRet = True
 
        Case acLBOpen
            varRet = Timer
 
        Case acLBGetRowCount
            varRet = m_tLDBInfo.intUserCount + 1
 
        Case acLBGetColumnWidth
            'Set the widths of the column
            'TWIPS converts to the appropriate
            'VBA Units of measurements, TWIPS.
            Select Case varCol
                Case 0:  varRet = 1.5 * TWIPS
                Case 1:  varRet = 1.5 * TWIPS
                Case 2:  varRet = 0.9 * TWIPS
                Case 3:  varRet = 0.9 * TWIPS
                Case 4:  varRet = 0.9 * TWIPS
            End Select
 
        Case acLBGetColumnCount
            varRet = (IIf(m_blnUseRosterLayout, ROSTER_COLUMN_COUNT, COLUMN_COUNT))
 
        Case acLBGetValue
            'Return the particular class member's value
            'depending on which column is being populated
            Select Case varCol
                Case 0:
                    ' First row contains column headings
                    If m_tLDBInfo.intUserCount = 0 Or (Me.optDisplayOptions) = 8 Then
                        Me.lblErrorMsg.Caption = IIf(m_blnUseRosterLayout, ROSTER_ERROR_MSG, m_tLDBInfo.strErrorMsg)
                        If varRow = 0 Then
                            varRet = vbNullString
                        End If
                    Else
                        Me.lblErrorMsg.Caption = vbNullString
                        If varRow = 0 Then
                            If IsNull(Me.txtDBPath) Then
                                varRet = vbNullString
                            Else
                                varRet = "Nom de machine"
                            End If
                        Else
                            varRet = m_tLDBInfo.atLUI(varRow - 1).strMachineName
                        End If
                    End If
                    
                Case 1:
                    If varRow = 0 Then
                        If m_tLDBInfo.intUserCount = 0 Or (Me.optDisplayOptions) = 8 Then
                            varRet = vbNullString
                            Me.lblErrorMsg.Caption = IIf(m_blnUseRosterLayout, ROSTER_ERROR_MSG, m_tLDBInfo.strErrorMsg)
                        Else
                            Me.lblErrorMsg.Caption = vbNullString
                            varRet = "Nom d'usager"
                        End If
                    Else
                        If m_tLDBInfo.intUserCount = 0 Then
                            varRet = vbNullString
                        Else
                            varRet = m_tLDBInfo.atLUI(varRow - 1).strUserName
                        End If
                    End If
                Case 2:
                    If varRow = 0 Then
                        If m_tLDBInfo.intUserCount = 0 Then
                            varRet = vbNullString
                            Me.lblErrorMsg.Caption = IIf(m_blnUseRosterLayout, ROSTER_ERROR_MSG, m_tLDBInfo.strErrorMsg)
                        Else
                            Me.lblErrorMsg.Caption = vbNullString
                            varRet = "Login Name"
                        End If
                    Else
                        If m_tLDBInfo.intUserCount = 0 Then
                            varRet = vbNullString
                        Else
                            varRet = m_tLDBInfo.atLUI(varRow - 1).strLoginName
                        End If
                    End If
                Case 3:
                    If varRow = 0 Then
                        If m_tLDBInfo.intUserCount = 0 Then
                            varRet = vbNullString
                            Me.lblErrorMsg.Caption = IIf(m_blnUseRosterLayout, ROSTER_ERROR_MSG, m_tLDBInfo.strErrorMsg)
                        Else
                            Me.lblErrorMsg.Caption = vbNullString
                            varRet = "Connected?"
                        End If
                    Else
                        If m_tLDBInfo.intUserCount = 0 Then
                            varRet = vbNullString
                        Else
                            varRet = CStr(CBool(m_tLDBInfo.atLUI(varRow - 1).blnConnected))
                        End If
                    End If
                Case 4:
                    If varRow = 0 Then
                        If m_tLDBInfo.intUserCount = 0 Then
                            varRet = vbNullString
                            Me.lblErrorMsg.Caption = IIf(m_blnUseRosterLayout, ROSTER_ERROR_MSG, m_tLDBInfo.strErrorMsg)
                        Else
                            Me.lblErrorMsg.Caption = vbNullString
                            varRet = "Suspect State?"
                        End If
                    Else
                        If m_tLDBInfo.intUserCount = 0 Then
                            varRet = vbNullString
                        Else
                            varRet = m_tLDBInfo.atLUI(varRow - 1).varSuspectState
                        End If
                    End If
            End Select
    End Select
 
    fListFill = varRet
ExitHere:
    Exit Function
ErrHandler:
    Resume ExitHere
End Function
 
Would be easier if you just stepped through your code and debugged line by line.

IIF()s are unique in that they process the False condition, even if the condition evaluates true. For instance, IIF(You=You,ValTrue,ValFalse) --- the program still evaluates ValFalse even if is null or empty (which may cause errors), while ValTrue is returned.

But when I think of an overflow error, it typically means mismatched datatypes. Exempli Gratia:
Putting too big of a number into an integer field
Putting too large of a string into a text field

Maybe that will help you find the problem, as I have too much work of my own to debug today.
 
I'll try and change the value types.

Thx!
 

Users who are viewing this thread

Back
Top Bottom