dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: [RESOLVED] runtime error 380 - invalid property value

  1. #1
    Join Date
    May 2005
    Posts
    126

    [RESOLVED] runtime error 380 - invalid property value

    Hello

    I have a private sub called Vullistview. When i load my program, this sub is called, and a listview is loaded with some data from an access file. No problem.

    I also want to call this sub when an user clicks an a tabstrip. So i call the sub again, and then i get this error.

    This is the sub :
    Private Sub Vullistview()
    Dim liRes As ListItem

    Set adoRs.ActiveConnection = adoCn
    With adoRs
    .LockType = adLockReadOnly
    .CursorType = adOpenKeyset
    .Open "select * from tblBuizen"
    End With
    lvRes.ListItems.Clear
    Do While Not adoRs.EOF
    Set liRes = frmNoroCat.lvRes.ListItems.Add(, , adoRs!ArtNr)
    liRes.SubItems(1) = adoRs!DN
    liRes.SubItems(2) = adoRs!Lengte
    liRes.SubItems(3) = adoRs!wanddikte
    liRes.SubItems(4) = adoRs!Materiaal
    adoRs.MoveNext
    Loop
    adoRs.Close

    End Sub
    When debugging, the error proints to the line : leRes.Subitems(1) = adoRs!DN
    Thanks

  2. #2
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: runtime error 380 - invalid property value

    If the sub runs without error the first time, it should work the second time, too.

    The only help I could offer is some debugging aid.

    The error occurs within a Do While Loop. Try to find if it occurs already for the first loop or later. Maybe the database gives no record and the ListItem is not created.
    Check if liRes is a valid ListItem at error time. You can put a breakpoint there and examine liRes with the cursor. It says "Nothing" if there is no ListItem created, and that's what I suspect...

  3. #3
    Join Date
    May 2005
    Posts
    126

    Re: runtime error 380 - invalid property value

    Thanks for your reply!

    This is the code for calling when the tabstrip is clicked.
    Private Sub TabStrip1_Click()
    Dim Tabindex As Integer
    Dim intB As Integer

    Tabindex = TabStrip1.SelectedItem.Index
    Tabindex = Tabindex - 1
    For intB = 0 To 1
    fraZoek(intB).Visible = False
    If intB = Tabindex Then fraZoek(intB).Visible = True
    Next intB

    lvRes.ListItems.Clear
    Call Vullistview

    End Sub
    In the sub form_load i call the sub Vullistview, without errors. When i add the line 'Call Vullistview' in the sub Tabstrip1_Click, i get the error.
    The strange thing is that the errors occurs when loading!

    When i debug and i put the cursor over liRes.SubItems(1) i get : invalid property value
    when i hold the cursor over adoRs!DN i get the value from the database.

    I can add the form with code i you need it.

    Thanks, Koen

  4. #4
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: runtime error 380 - invalid property value

    From looking at your code excerpts I have no idea. Everything seems perfectly alright. And you say, the routine runs well at form_load() time...

    If you could provide a small working sample including a little sample-database I could try to do more detective's work...

  5. #5
    Join Date
    May 2005
    Posts
    126

    Re: runtime error 380 - invalid property value

    I added my files. Why, when running the program, is the tabstrip1_click sub called? T thought is would only run when clicked? (this has nothing to do with my problem)

    I think i has something to do with the tabstrip? Because, i can call the sub Vullistview, without problems from cmbCategorie_click event.


    Oh, when you are looking anyway. How can i sort the comboboxes in a way that first i got "Alles" (= everything) and then the numbers sorted?

    I can't upload the database.

    Thanks
    Attached Files Attached Files
    Last edited by koenbuytaert; July 20th, 2007 at 07:07 AM.

  6. #6
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: runtime error 380 - invalid property value

    Ok.
    1. You should have posted the project file .vbp, too, because it contains all the necessary references for the program to run.
    2. Is it not possible to make a very small sample database for demo purposes? Because the program would not run far enough without one, for me to find any error.
    3. A proposal: to make your program more independant from where it would be run, don't use absolute path specs like
    strPath = "C:\Documents and Settings\Koen\Mijn documenten\visual basic 6.0\VB98\NoroCat\"
    for the database and the picture. Use relative references like app.path which is always the path of your app, wherever you started it from and it will work for me and you without me having to search and change all these absolute references.
    For example your picture file specification will be fully qualified by app.path & "\Norocat.jpg" as well.
    Thank you.

  7. #7
    Join Date
    May 2005
    Posts
    126

    Re: runtime error 380 - invalid property value

    I want to upload, but i can't, i get error invalid file type, both for the database file as the .vbp file.

    Is there a way?

    Thanks

  8. #8
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: runtime error 380 - invalid property value

    Yes, certainly. Put all the files together into a Zip-compressed folder, which is easy in Windows XP:
    Mark all files you want to put and right click and select "Send to..." -> "Zip-compressed folder"
    This creates an archive file xxx.zip, which you can attach easily to your post.

  9. #9
    Join Date
    May 2005
    Posts
    126

    Re: runtime error 380 - invalid property value

    Thanks!!
    Attached Files Attached Files

  10. #10
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: runtime error 380 - invalid property value

    Ah, well everything seems clear now.

    Ok. In your Form_Load() you have the following code
    Code:
    'Tabstrip specificaties
    Set TabStrip1.SelectedItem = TabStrip1.Tabs(1)
    just before you create the columns in your ListView.
    Now this line of code causes the TabStrip1_Click() routine to be executed, because it selects a tabstrip like clicking on it.
    This in turn causes Vulllistview to be called, which tries to fill SubItems() which aren't yet defined.

    Proper solution:
    Delete this Set TabStrip... line from where it is and put it further down in your Form_Load() code.
    It seems to work perfectly if you put it directly after Call Vulcombos like that:
    Code:
    'vul combos
    Call Vulcombos
    
    'Tabstrip specificaties
    Set TabStrip1.SelectedItem = TabStrip1.Tabs(1)
    This makes it sure that your .Open "Select * From " & "tbl" & cmbCategorie.Text works, which will otherwise fail because the cmbCategorie is not filled yet.

    Very good implementing the app.path refs already. I had no trouble starting and running your code.

  11. #11
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: runtime error 380 - invalid property value

    Oh yes... I forgot:
    If you have put the Set TabStrip1.SelectedItem... statement after the Call Vulcombos, you dont need the following Call Vullistview anymore, because this routine is called from within the TabStrip1_Click() routine which is executed as explained.

    And don't forget to take away the outcommenting of Call Vullistview in your TabStrip1_Click().
    Last edited by WoF; July 20th, 2007 at 10:19 AM.

  12. #12
    Join Date
    May 2005
    Posts
    126

    Re: runtime error 380 - invalid property value

    Thanks very much!!!

    I did't realised about the tabstrip1.selecteditem.....
    Now it makes sense.
    I am no programmer, last year i made my own veterinary sofware package, with a lot of help from this forum. Now, i make this program for a friend of mine. I said i would try it, it would make his life easier he had said.

    What do you mean with "And don't forget to take away the outcommenting of Call Vullistview in your TabStrip1_Click()." ?

    Thanks again.

  13. #13
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: runtime error 380 - invalid property value

    You are welcome.

    At the end of the Sub TabStrip1_Click() there is a statement
    Code:
      'Call Vullistview
    It was obviously commented out (deactivated by putting a comments sign ' in front of it), because it caused the trouble. You'd have to reactivate this statement again, because now it makes sense executing it there. Then you'll have a full list already first time after the form has loaded.

    P.S.: You are doing well for a non-programmer. Keep it up.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)