Results 1 to 7 of 7
  1. #1
    Ashe is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Location
    Blacksburg VA
    Posts
    65

    Access Control- compile error and object support error


    I am baffled by this: The code for one of my forms was getting hung up on

    "If Len(Me!lstTargetRank.SelText) < 1 Then"

    It was kicking back a compile error and highlighting the section "SelText.: After searching the forums, I decided the form must be corrupt, so I copied the controls and code to a new blank form. Now it's getting hung up at this same place (from what I can tell) and says "Object doesn't support this property or method"

    This is really odd, because I have used this block of code a hundred times over and it always works.

    Is there a reference I lost? Any advice?

    Thanks in advance!

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Is this a list box? A listbox doesn't have a SelText property. A text box does.

  3. #3
    Ashe is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Location
    Blacksburg VA
    Posts
    65
    Yup. It's a listbox. I tried replace SelText with Text and Value, but still getting the same "object does not support error." Is .Text the appropriate function for a list box?

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    So what are you trying to check? If there is a selection? If so, and your listbox has the multiselect property set to NO, then you can just check to see if it is not null.

    If Not IsNull(Me.lstTargetRank) Then ...

    or if it has multiselect set to SIMPLE or EXTENDED then

    If Me.lstTargetRank.ItemsSelected.Count > 0 Then

  5. #5
    Ashe is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Location
    Blacksburg VA
    Posts
    65
    I need to know what the text value is to use it in a subsequent query...

  6. #6
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    If it is single select then it just use

    Me.lstTargetRank


    If it is multiselect you will need a function to return the values as you have to iterate through the selected items.

  7. #7
    Ashe is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Location
    Blacksburg VA
    Posts
    65
    Yes! This worked. Thank you!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 02-03-2011, 07:13 AM
  2. new compile error!
    By darklite in forum Access
    Replies: 6
    Last Post: 09-02-2010, 05:13 PM
  3. compile error
    By darklite in forum Access
    Replies: 6
    Last Post: 08-31-2010, 04:27 PM
  4. Replies: 5
    Last Post: 08-05-2009, 04:07 PM
  5. Replies: 2
    Last Post: 02-28-2009, 03:31 PM

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
  •  
Other Forums: Microsoft Office Forums