Results 1 to 17 of 17

Thread: Property Access must assign to the property or use its value

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2016
    Posts
    28

    Property Access must assign to the property or use its value

    Hi,
    I created a windows form, then i have another menu kind of windows form to open other windows form. 2 menu button to divert to another windows form is working, only one is not working. I have tried creating a few windows form to test and all results the same. Below is the screenshot, please help. Thanks
    Name:  1.jpg
Views: 1314
Size:  24.5 KB

  2. #2
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    482

    Re: Property Access must assign to the property or use its value

    sales_report_qnty does not appear to be a proper form. If it was then the .show() method would have auto-capitalized to .Show().
    You may have to make backups of the related files, delete it and recreate the form and paste the code back in.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,350

    Re: Property Access must assign to the property or use its value

    Check the Solution Explorer to see whether that class shows the correct Form icon. I'll wager that it doesn't. Someone solved an issue like this recently but I can't recall which thread it was. I think that, if you open the designer code file for that form and one that's working, you may well be able to see what's missing in the broken one. I think that's what the other person did.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2016
    Posts
    28

    Re: Property Access must assign to the property or use its value

    Hi Guys,
    As Far as i've checked, everything seems the same, i have deleted and created another windows form and still the same. Let me know if there is any other suggestions. Thanks

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,539

    Re: Property Access must assign to the property or use its value

    What happens if you create an instance of that form and show it? Instead of using the default instance, create an explicit instance and see if that works.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,350

    Re: Property Access must assign to the property or use its value

    Quote Originally Posted by techgnome View Post
    What happens if you create an instance of that form and show it? Instead of using the default instance, create an explicit instance and see if that works.

    -tg
    That's a very good point. Have you, by any chance, added a constructor with one or more parameters to that form without also adding a parameterless constructor? If so then that form will have no default instance because a parameterless constructor is required to create a default instance.

  7. #7
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,539

    Re: Property Access must assign to the property or use its value

    What I'm wondering is if there's a problem with the constructor/initialization of the form that prevents the default instance from being created, and so it isn't able to assign the property a value, which would result in the error above. On a side note, I wouldn't have different forms for what appears to be the same report, just with different parameters or groupings... I'd have a single report that could handle it all, but modify itself depending on the parameters. Then I'd simply show that form (or rather an instance of it) passing it the different parameters so it shows correctly ... but then again, I know diddly about the report and am simply going based on the code in the screenshot, I think I'll shaddup now...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,350

    Re: Property Access must assign to the property or use its value

    Quote Originally Posted by techgnome View Post
    What I'm wondering is if there's a problem with the constructor/initialization of the form that prevents the default instance from being created, and so it isn't able to assign the property a value, which would result in the error above.
    What you're describing sounds like it would generate a run time error though, rather than a compilation error.

  9. #9
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,902

    Re: Property Access must assign to the property or use its value

    Just another straw to clutch at but is it possible you've accidentally removes the "inherits Form" line from the designer code?
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  10. #10
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    Re: Property Access must assign to the property or use its value

    Talking of straws....

    What happens if you right click on the word show and select "Go To Definition" in the context menu? Does it take you to an actual Property definition.... or somewhere else?

  11. #11
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,539

    Re: Property Access must assign to the property or use its value

    Quote Originally Posted by jmcilhinney View Post
    What you're describing sounds like it would generate a run time error though, rather than a compilation error.
    You'd think so, and yet it wouldn't have been the weirdest thing I've seen in VS.


    Quote Originally Posted by Inferrd View Post
    Talking of straws....

    What happens if you right click on the word show and select "Go To Definition" in the context menu? Does it take you to an actual Property definition.... or somewhere else?
    Actually, I now wonder if there is a property that's been added to the form called "Show" ... that would cause the compiler to get confused...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  12. #12
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    Re: Property Access must assign to the property or use its value

    Quote Originally Posted by techgnome View Post
    Actually, I now wonder if there is a property that's been added to the form called "Show" ... that would cause the compiler to get confused...
    That's what I was thinking. A Property definition for show with a small s as seen in the attachment.

    Creating a property named show should give a compiler warning, though warnings are easier to miss than errors.

    Without the Property definition, "Go To Definition" takes me to the Object Browser in VS2010, and somewhere confusing I've never been before in VS2015.

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Mar 2016
    Posts
    28

    Re: Property Access must assign to the property or use its value

    Hi All,
    Thanks for your reply, i found the solution. I just change the part below and it worked. Previously it was set as textbox, i changed it to the form name. Thanks
    Name:  1.jpg
Views: 1160
Size:  33.4 KB

  14. #14
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,350

    Re: Property Access must assign to the property or use its value

    So, you're saying that you had a TextBox on the form containing the code with the same name as the form you want to open?

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Mar 2016
    Posts
    28

    Re: Property Access must assign to the property or use its value

    Hi,
    No, the form name and text box not the same, but for some reason, (Im not sure what you call the bar up there) it defaults to textbox name, later i changed it and save, after that it was fine. Thanks

  16. #16
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,350

    Re: Property Access must assign to the property or use its value

    Quote Originally Posted by carlson_46 View Post
    Hi,
    No, the form name and text box not the same, but for some reason, (Im not sure what you call the bar up there) it defaults to textbox name, later i changed it and save, after that it was fine. Thanks
    That doesn't actually make any sense but I guess it's a moot point as what you wanted to work is working and that's what matters.

  17. #17

    Thread Starter
    Junior Member
    Join Date
    Mar 2016
    Posts
    28

    Re: Property Access must assign to the property or use its value

    Yup, as long it is working, Im Happy.

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