+ Reply to Thread
Results 1 to 12 of 12

Syntax for returning Optionbutton (Userform) caption (Error 438 with ctr.value)

  1. #1
    Forum Contributor
    Join Date
    02-09-2010
    Location
    Constanta
    MS-Off Ver
    Excel 2007
    Posts
    128

    Syntax for returning Optionbutton (Userform) caption (Error 438 with ctr.value)

    Greetings,

    I would like to return the name of the optionbutton that has been selected in Frame1. In addition to other optionbuttons, a textbox and combobox are included in the frame.

    I used the following code:

    Please Login or Register  to view this content.
    But I get a run-time error 438 : object doesn't support this property or method. When I changed

    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    I was able to get the desired result. I am trying to understand why I would not get the desired result using the "Value" property.

    Attached is a sample file.

    Thanks for your help.
    Asha

    Attached Files Attached Files
    Last edited by asha3010; 07-13-2010 at 08:17 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Syntax for returning Optionbutton (Userform) caption (Error 438 with ctr.value)

    Hi asha3010

    Try this..
    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Contributor
    Join Date
    02-09-2010
    Location
    Constanta
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Syntax for returning Optionbutton (Userform) caption (Error 438 with ctr.value)

    Thanks a lot Pike. Your code worked.

    Do you know why ctr.value returned an error? Trying to learn so that I don't make the same mistake again.

    Thanks
    Asha

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Syntax for returning Optionbutton (Userform) caption (Error 438 with ctr.value)

    .value is not a constant/ property of a control

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Syntax for returning Optionbutton (Userform) caption (Error 438 with ctr.value)

    do you use
    Please Login or Register  to view this content.
    with the immediate window to track your code .
    also both the parameter window and object library are helpful

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Syntax for returning Optionbutton (Userform) caption (Error 438 with ctr.value)

    If you use optionbuttons in a userform, and label15 is also in this userform

    Please Login or Register  to view this content.
    If you use optionbuttons (Active-X-controls) in a sheet, and label15 is also in this sheet

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    02-09-2010
    Location
    Constanta
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Syntax for returning Optionbutton (Userform) caption (Error 438 with ctr.value)

    Thanks Pike & snb for your responses.

    I am not familiar with Debug.Print - I will look it up for future use.

    Here's an interesting (atleast for me!) observation. The code I initially had and that provided by snb do not work if the frame contains a label control. For whatever reason, if there is no label control, ctr.value does not return an error.

    I have attached a sample file to demonstrate this.

    Any ideas why this is the case?

    Thanks again for your support
    Asha
    Attached Files Attached Files

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Syntax for returning Optionbutton (Userform) caption (Error 438 with ctr.value)

    Not all controls have a Value property; Labels do not for instance, hence the error with the original version. If you move the Value check so that it is after (and separate from) the check for the control's type (which is effectively what Pike did) then you don't have the problem.
    Remember what the dormouse said
    Feed your head

  9. #9
    Registered User
    Join Date
    03-02-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Syntax for returning Optionbutton (Userform) caption (Error 438 with ctr.value)

    Quote Originally Posted by romperstomper View Post
    Not all controls have a Value property; Labels do not for instance, hence the error with the original version. If you move the Value check so that it is after (and separate from) the check for the control's type (which is effectively what Pike did) then you don't have the problem.
    Hi Everybody! I just registered and I am having an issue similar to this one!

    I am trying to change an userform caption... the code is like this:

    Please Login or Register  to view this content.

    So basically I have a string variable with the name of the object I am changing the caption. After that I am adding conutry name of that particular userform. But the error is the same: Object doesn't support this property or method

    Anyone now how to deal with it?

    Thanks in advance and hope to share experiences and knowledge here!

    Cheers,
    Rodrigo

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Syntax for returning Optionbutton (Userform) caption (Error 438 with ctr.value)

    Hi, and welcome to the forum!

    Unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

    Once you do that, I'm sure you'll get a prompt answer.

  11. #11
    Registered User
    Join Date
    03-02-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Syntax for returning Optionbutton (Userform) caption (Error 438 with ctr.value)

    Quote Originally Posted by romperstomper View Post
    Hi, and welcome to the forum!

    Unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

    Once you do that, I'm sure you'll get a prompt answer.

    I am sorry about that! I will open a new one right now!

    Thanks for the advice!

  12. #12
    Registered User
    Join Date
    03-02-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    10

    Run-time Error 438: Object doesn't support this property or method

    Error Message. Sorry
    Last edited by rodrigorpinto; 03-02-2011 at 11:27 AM. Reason: Error

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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