Results 1 to 11 of 11

Thread: run time error 380

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Location
    Dhaka, Bangladesh
    Posts
    222

    run time error 380

    "Invalid property value"
    for show data in list view i write code
    Code:
    Private Sub Form_Load()
    Dim i As Integer
    Call path
    SQL = "select * from material"
    Set rs = New ADODB.Recordset
    
    
     i = 1
     rs.Open SQL, Adb, adOpenDynamic, adLockOptimistic
            Do While Not rs.EOF
                LVEmp.ListItems.Add i, , i
                LVEmp.ListItems(i).SubItems(1) = rs!id
                LVEmp.ListItems(i).SubItems(2) = rs!Name
                LVEmp.ListItems(i).SubItems(3) = rs!unit
                i = i + 1
                rs.MoveNext
            Loop
        rs.Close
    End Sub
    when I run it then show this msg. and highlight this line
    Code:
    LVEmp.ListItems(i).SubItems(1) = rs!id

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: run time error 380

    Try
    vb Code:
    1. Dim i As Integer
    2. Dim lvwItem As Listitem
    3. Call Path
    4. SQL = "select * from material"
    5. Set rs = New ADODB.Recordset
    6.  
    7.  
    8.  i = 1
    9.  rs.Open SQL, Adb, adOpenDynamic, adLockOptimistic
    10.         Do While Not rs.EOF
    11.             Set lvwItem = LVEmp.ListItems.Add(i, , i)
    12.             lvwItem.SubItems(1) = rs!id
    13.             lvwItem.SubItems(2) = rs!Name
    14.             lvwItem.SubItems(3) = rs!unit
    15.             i = i + 1
    16.             rs.MoveNext
    17.         Loop
    18.     rs.Close
    19. End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Location
    Dhaka, Bangladesh
    Posts
    222

    Re: run time error 380

    sorry. after try your code that msg again show.

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: run time error 380

    What is the value of rs!id

    Check it manually by inserting this one line before...

    Code:
    Msgbox rs!id
    If the value is correct then try

    Trim(rs!id) before setting it as a value....
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5
    Hyperactive Member jp26198926's Avatar
    Join Date
    Sep 2008
    Location
    General Santos City, Philippines
    Posts
    310

    Re: run time error 380

    Try Add ColumnHeaders..

    Code:
    Private Sub Form_Load()
    Dim i As Integer
    Call path
    SQL = "select * from material"
    Set rs = New ADODB.Recordset
    
    LVEmp.View = lvwReport
    
    LVEmp.ColumnHeaders.Add , , "Count"
    LVEmp.ColumnHeaders.Add , , "ID"
    LVEmp.ColumnHeaders.Add , , "Name"
    LVEmp.ColumnHeaders.Add , , "Unit"
    
     i = 1
     rs.Open SQL, Adb, adOpenDynamic, adLockOptimistic
            Do While Not rs.EOF
                LVEmp.ListItems.Add i, , i
                LVEmp.ListItems(i).SubItems(1) = rs!id
                LVEmp.ListItems(i).SubItems(2) = rs!Name
                LVEmp.ListItems(i).SubItems(3) = rs!unit
                i = i + 1
                rs.MoveNext
            Loop
        rs.Close
    End Sub
    "More Heads are Better than One"

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Location
    Dhaka, Bangladesh
    Posts
    222

    Re: run time error 380

    Quote Originally Posted by koolsid View Post
    What is the value of rs!id

    Check it manually by inserting this one line before...

    Code:
    Msgbox rs!id
    If the value is correct then try

    Trim(rs!id) before setting it as a value....
    it is manually insert. when I use your code msg show: 1. and then show that msg. if i use trim(rs!id) not solve.

  7. #7
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: run time error 380

    Abu, Can I see you project? If you want, you can also mail it to me...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  8. #8
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: run time error 380

    Make sure your listview has at least 4 columns at design time, otherwise you will hit error 380 when you use ....SubItems(x) where x = 1, 2 or 3.
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Location
    Dhaka, Bangladesh
    Posts
    222

    Re: run time error 380

    Quote Originally Posted by anhn View Post
    Make sure your listview has at least 4 columns at design time, otherwise you will hit error 380 when you use ....SubItems(x) where x = 1, 2 or 3.
    In design time I use 4 colums header. now show a msg: "invalid use of null" and then select this line
    Code:
      lvwItem.SubItems(3) = rs!unit
    now I what need to do.

  10. #10
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: run time error 380

    What is the value of rs!unit?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  11. #11
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: run time error 380

    Quote Originally Posted by abu taher View Post
    In design time I use 4 colums header. now show a msg: "invalid use of null" and then select this line
    Code:
      lvwItem.SubItems(3) = rs!unit
    now I what need to do.
    A subitem cannot have Null value. If rs!unit is Null then you have convert it to "" (empty string), perhaps like this:
    Code:
      lvwItem.SubItems(3) = "" & rs!unit
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width