+ Reply to Thread
Results 1 to 6 of 6

Debugging Error 380

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-06-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    180

    Debugging Error 380

    Hi All,

    I really can't understand this but i have the same code in 2 files. It works in on 1 file but not on the other and both are saved in the same file location. The error I keep getting is 380 the code I am using is below. The error occurs at this point of the code:

    Me.Controls("Reg" & x).Value = findvalue
    Private Sub lstLookup_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    'Unprotect Sheet
        Sheet1.Unprotect
    
    'declare the variables
        Dim sessionID As String
        Dim i As Integer
        Dim findvalue
    
        
        'error block
        On Error GoTo errHandler:
        'get the select value from the listbox
        For i = 0 To lstlookup.ListCount - 1
            If lstlookup.Selected(i) = True Then
                sessionID = lstlookup.Value
               
            End If
        Next i
        'find the session ID number
        Set findvalue = Sheet1.Range("B:B").Find(What:=sessionID, LookIn:=xlValues)
        'add the database values to the userform
        cNum = 20
        For x = 1 To cNum
            Me.Controls("Reg" & x).Value = findvalue
            Set findvalue = findvalue.Offset(0, 1)
        findvalue.EntireRow.Select
        Next
        'disable adding
        'Me.CmdAdd.Enabled = False
        'Me.CmdSave.Enabled = True
        'error block
        On Error GoTo 0
        Exit Sub
    
    errHandler::
        MsgBox "An Error has Occurred  " & vbCrLf & "The error number is:  " _
               & Err.Number & vbCrLf & Err.Description & vbCrLf & _
               "Please notify the administrator"
    'Protect Sheet
        Sheet1.Protect
    
    End Sub
    Any ideas or help greatly appreciated as always.

    Cheers,

    forrestgump1980

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,298

    Re: Debugging Error 380

    What kind of control is it, what's the value of the variable when the code breaks?
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    06-06-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    180

    Re: Debugging Error 380

    the value of the variable is one of the following (MK-1, MK-33, MK-44), the control is a combobox. Thanks for your help.

  4. #4
    Forum Contributor
    Join Date
    06-06-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    180

    Re: Debugging Error 380

    I think it has something to do with this code here:

    Private Sub Reg1_Change()
    
    ' Declare the values
    Dim sessionCode As String
    Dim findvalue As Range
    
    ' Define the variable
    sessionCode = Reg1.Value
    
    ' Set the search range
    Set findvalue = Sheet7.Range("B:B").Find(What:=sessionCode, LookIn:=xlValues)
    
    ' Link the active cell with the fruit and offset twice, then link offset to textboxs
    Me.Reg1.Value = findvalue.Value
    Me.Reg2.Value = findvalue.Offset(0, 1).Value
    Me.Reg3.Value = findvalue.Offset(0, 2).Value
    Me.Reg4.Value = findvalue.Offset(0, 3).Value
    Me.Reg5.Value = findvalue.Offset(0, 4).Value
    Me.Reg25.Value = findvalue.Offset(0, 6).Value
    Me.Reg26.Value = findvalue.Offset(0, 7).Value
    Reg25.Value = Format(Reg25.Value, "$#,###,###")
    End Sub

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,298

    Re: Debugging Error 380

    I mean what is the actual value when the code breaks, not what you think it should be.

    Are the values you are trying to assign contained in the lists for each control?

  6. #6
    Forum Contributor
    Join Date
    06-06-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    180

    Re: Debugging Error 380

    I have actually managed to resolve the code to sort out the issue:

    Private Sub lstLookup_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    'Unprotect Sheet
        Sheet1.Unprotect
    
    'declare the variables
        Dim sessionID As Integer
        Dim i As Integer
        Dim findvalue
        
        'error block
        On Error GoTo errHandler:
        'get the select value from the listbox
        For i = 0 To lstlookup.ListCount - 1
            If lstlookup.Selected(i) = True Then
                sessionID = txtlookup.Value
               Range("C1").Value = lstlookup.Value
            End If
        Next i
        'find the session ID number
        Set findvalue = Sheet1.Range("B:B").Find(What:=sessionID, LookIn:=xlValues)
     findvalue.Select
        'add the database values to the userform
          
        Me.Reg1 = ActiveCell.Offset(0, 1).Value
        Set findvalue = Sheet1.Range("B:B").Find(What:=sessionID, LookIn:=xlValues)
       
        CNum = 31
        For x = 0 To CNum
        Me.Controls("Reg" & x).Value = ActiveCell.Offset(0, x).Value
        Set findvalue = Sheet1.Range("B:B").Find(What:=sessionID, LookIn:=xlValues)
        Set findvalue = findvalue.Offset(0, 1)
        Next
        
        'disable adding
        'Me.CmdAdd.Enabled = False
        'Me.CmdSave.Enabled = True
        'error block
        On Error GoTo 0
        Exit Sub
    
    errHandler::
        MsgBox "An Error has Occurred  " & vbCrLf & "The error number is:  " _
               & Err.Number & vbCrLf & Err.Description & vbCrLf & _
               "Please notify the administrator"
    'Protect Sheet
        Sheet1.Protect
    
    End Sub
    Thank you for all your help. It got me back on the right lines. Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Debugging Error (2007 vs 2010)
    By dagindi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-02-2013, 01:51 PM
  2. Debugging Array Error
    By jo15765 in forum Excel General
    Replies: 4
    Last Post: 12-10-2011, 03:18 AM
  3. Debugging Code Error
    By gurpreet161 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-27-2011, 01:30 AM
  4. ODBC error and debugging
    By aharreluark in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-03-2010, 10:36 AM
  5. Startup Error debugging help
    By Ron Rosenfeld in forum Excel General
    Replies: 2
    Last Post: 02-03-2005, 05:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1