+ Reply to Thread
Results 1 to 9 of 9

Form Control passed as a parameter loses functionality (.Clear method)

  1. #1
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Buffalo, NY
    MS-Off Ver
    Office 365
    Posts
    286

    Form Control passed as a parameter loses functionality (.Clear method)

    I have a strange situation with one of my ongoing developments. Briefly, I am passing a form control (almost always a ComboBox) as a parameter to a function in a class. The function scans the class, and loads entries that match a set of filters, into the list portion of the control. Naturally, one of the parameters is ClearList? - do you want to clear the list before starting. This allows two scans to piggybacked on top of each other.

    When the ClearList parameter is set to true (the default) we call the .Clear method of the control, which clears the list (only) of the control, but leaves any text box (for a ComboBox) unaffected.

    The problem is that sometimes the Clear operation doesn't work. In truth, I suspect that every time the Clear operation doesn't work, but the first time the list is already empty.

    The method works fine in a less complex environment, but doesn't work when the control is addressed indirectly (the control is itself a parameter).

    I'm using this as an incremental search and display as a search value is built - rather like the way in which Google puts suggestions in the results are as you type in your search term. The net result is that as the list should be getting shorter (we are approaching the definitive, unique search value) it actually seems to begetting longer, because the list isn't being cleared properly.

    I have a lab tool where the calls are emulated by buttons on the console of the tool, and there is never any problem clearing the list.

    I realize that this is tough to visualize from only a description, so I've attached the actual workbook, and also the lab tool.

    The Actual workbook is LMS.- Library Management System. It installs in a directory, and produces two traces:

    LMS-Library Management SYstem EVTrace.txt - a trace of the form events, as they fire
    LMS-LibraryManagement System Trace.txt - a more detailed trace of activites - needs source code!

    These two files are best printed in landscape format to pre3serve linear formatting.
    To 'play' with the system, you'll need to load LMSForm, and run it using f5.
    Tab to the Title combobox of the Books page (default page), and type in:

    The Unan (just 8 characters)

    The combobox list begins to show possibilities as you get past 4 characters, and then rather than eliminating poibilities (by clearing the list), the list becomes clogged with 'impossibilities'.

    Use Exit to get out, and explore the trace files, and/or the source files.
    The procedures of interest are the Change procedure of me.cboBookTitle, in LMSForm, and the function
    LoadListControlEntries in the classclBook. I've extracted both procedures to a code box.

    cboBookTitle_Change
    Please Login or Register  to view this content.
    Function LoadListControlEntries
    Please Login or Register  to view this content.
    LMS is too big to upload directly, so I've put it in a .zip file by itself.

    The Labtool is in ComboBoxLab.xlsm, and the same method of activating it applies, as do the two trace files. This is really only a lab tool for me, but you should be able to explore it and see how thecombobox functions when prodded.

    I'm now going out for a long walk!

    Tony
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Form Control passed as a parameter loses functionality (.Clear method)

    Just to make sure I understand you very extended question.
    What you want is the List to filter as you type? Correct?
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Buffalo, NY
    MS-Off Ver
    Office 365
    Posts
    286

    Re: Form Control passed as a parameter loses functionality (.Clear method)

    Yes - the effect is that the list filters down as the typing progresses (with the small test dataset it converges very ralidy indeed). However, the problem is that the control is not clearing. And the only change in the situation that I can find is the use of the control as a parameter.
    Tony

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Form Control passed as a parameter loses functionality (.Clear method)

    I took a quick look at the VBA code and all the classes you're using; it didn't make things clear for me.
    These 'trace files' ( the text files) what do they really do, can't really follow them when I step through the code.
    Let me ask it this way.
    You have a multipage userform.
    Are the contents showing up to be dependent of what you entered in one of the other pages or are these separate actions?
    Len me stick to the Books.

    You have some dropdown lists which I imagine are the ones that you want populated to be able to select an author, publisher or ISBN number.
    I do see that the ISBN filed is not a dropdown and also, you type something in but nothing happens.

    Why don't you filter directly on the table as you type.
    You could add a listbox at the bottom of the userform's page that shows only the records as you type, for example just one textbox where you start typing anything and if will start filtering and cross check the ISBN number or the author's name or the publisher and if you click the item you want to look at in the listbox, populates the userform.
    I use this with my lists and have been putting it to use with quite large tables for projects I'm working on and must say the users like this.
    Maybe my explanation doesn't paint a picture, I'm not that great at explaining it

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Form Control passed as a parameter loses functionality (.Clear method)

    Here are three screenshots of one of my userforms.
    001 is the userform in edit mode
    002 is entering the 'me' in the text(search)box showing 3 records that contain the text 'me' in one or more fields
    003 the populated form showing the data of the selected record in the listbox
    Attached Images Attached Images

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Form Control passed as a parameter loses functionality (.Clear method)

    I put together my idea.
    If you press the shape in the worksheet books you'll see the userform and you can enter your search text or directly select a record in the listbox
    Attached Files Attached Files

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Form Control passed as a parameter loses functionality (.Clear method)

    I'm sure you're very busy and it's a weekend so I don't expect an answer but I have a question about your version of the form.
    What's the exact reason of all the trace text files and does it have any special purpose?
    I also don't know why your original (zipped) file was so large. The file I attached is the same file only with my userform added to it.
    Have a nice weekend

  8. #8
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Buffalo, NY
    MS-Off Ver
    Office 365
    Posts
    286

    Re: Form Control passed as a parameter loses functionality (.Clear method)

    Well - it's resolved, but not with any success!

    Turns out the Clear method "simply" sets the ListCount to 0, and nulls out the very first entry in the list. The problem I was having was to raise the list (after the DropDown). There's no way to do this, except Clicking on the DropDownButton, when the list is already down;OR (which is what I was experiencing in the Lab environment, to Exit from the combobox control, at which point it "automatically" winds the list back in.

    Another example of a great idea being useless because of imperfect implementation. One boolean property (ListIsVisible) would have solved that.

    Special thanks to Keebellah in the Netherlands, for sympathetic listening!

    Resumes head bashing against wall.

    Tony

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Form Control passed as a parameter loses functionality (.Clear method)

    If the bandages on your head don't work anymore, why not send me the file again indicating the point where it 'hurts' ?
    I don't understand what you mean with the list.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Refer to Combobox passed as parameter by string variable name
    By TC1980 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-23-2016, 08:53 AM
  2. [SOLVED] Clear Form Control
    By mariannehislop in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-27-2014, 03:22 AM
  3. ActiveX control lose functionality when run as parameter to commandline excel.exe
    By vientito in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2014, 03:30 PM
  4. [SOLVED]Excel 2010 Passing form control as parameter fails
    By tfurnivall in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-17-2014, 01:03 AM
  5. [SOLVED] VBA: Array of User Defined Type passed as parameter to function
    By Bezzie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-14-2013, 07:08 AM
  6. [SOLVED] Function parameter loses ASCII value
    By 30thDrip in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-06-2013, 11:43 PM
  7. How to Clear Listbox Form Control
    By Mordred in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-25-2011, 11:37 AM

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