+ Reply to Thread
Results 1 to 30 of 30

userForm -> Frame 'top' value limited. Dynamically created controls,

  1. #1
    Registered User
    Join Date
    06-13-2013
    Location
    Katowice
    MS-Off Ver
    Office 2007
    Posts
    19

    userForm -> Frame 'top' value limited. Dynamically created controls,

    Hello,
    I'm working with MS Office 2007.
    I have an Access database with client's data. I'd like to show those data on Excel's user form in the frames generated dynamically - one frame for one client (frame caption value is sth like: 'Client number ' & guyNumber). On one frame there will be all of the data shown with dynamically generated labels and textboxes. All of those frames are placed inside the main frame (e.g. name: 'ListOfClients').
    Every client's frame has its height: 40. The frames are stored one under other. Scroll bar size of the main frame is also calculated dynamically, depending on numbers of client's.

    Until now it's easy.

    Now the problem is with placing all of those client's frames inside this main frame. As I mentioned, every frame is 40 px high so I calculated, that next frame's 'top' value will be: "guyNumber * 40" and it worked until I run it with the bigger database. I noticed that for number of clients bigger than ~820, excel shows: runtime error '6' - overflow.

    I couldn't find out where's the problem but I finally did: The calculated 'top' value is bigger than 32767 (Microsoft reccomends this value to be an integer not bigger than 32767, which is max for integer value). But I need more.
    Is there any solution or workaround to have those data correctly shown without any errors?

    I'll be glad for any solution.

    Best regards,
    Michal
    Last edited by kropeck; 08-18-2013 at 05:34 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Michal

    Do you need to use frames and have all the data on the userform at the same time?

    How about using a combobo/listbox where the user can pick the client and then the data is loaded into various controls on the userform?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    06-13-2013
    Location
    Katowice
    MS-Off Ver
    Office 2007
    Posts
    19

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Yeah.... so basically I thought about it, but there are too many data I would like to show without need of clicking the client's name just for first sight. The details will be shown after clicking on the frame (there are so much data about one client).
    Listbox is too....... simple. I can't do formatting like e.g.

    Client number: 000123 Name: John Smith Status: active
    Address: Paris Phone number: 00011122233 Payments: on-time

    And so on. By the way - the application window is 1200px wide, so there are much more data shown. I thought that 40px of frame highness (?) is enought to enter two lines of data and it will be readable, because each frame is distinguishing from others.

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Can't you put a search box at the top to filter the number of results? No-one in their right mind would want to scroll through that many records

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,001

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    FYI, there is nothing to stop you (other than good sense ) from adding controls with a Top value greater than 32767 - I suspect your error is simply down to using Integers in your calculation. If you use Longs (or Doubles) the code should work.
    Everyone who confuses correlation and causation ends up dead.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    How is the user going to find the data for a specific client?

    Will they need to scroll through the frames for all the other clients until they spot it?

    By the way, it was a combobox I was really suggesting but a listbox with something sort of filter, as Kyle suggests, would be a good idea to.

    Oh and the combobox/listbox would be for the client name/id, not the client data.

    The client data would be displayed with the same set of controls you are using in your frames.

  7. #7
    Registered User
    Join Date
    06-13-2013
    Location
    Katowice
    MS-Off Ver
    Office 2007
    Posts
    19

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    I'm really grateful that everyone is concerned about my application and want to help to prepare the GUI and stuff, but trust me - everything is well designed and it has all of searching features and everything needed for easy, intuitive and as-less-clicking-as-possible excel app.

    In this thread I'd like to understand what I'm doing wrong and how to solve this issue.

    romperstomper - when I first read your post I jumped on my chair - it must me that. Indeed in most of my application I user Integer as iterator. But I looked in my code and this is what I see:

    Please Login or Register  to view this content.
    Of course in my app I have "Option Explicit" so there's no possibility of having any variable undeclared. But how I might declare the value of ".Top" as Long or the last line: "ScreollHeight". What I found on some microsoft site is, that those values should be set as an integer (-32767 to 32767), but I tried to create some button with it's "TOP" value set as 50'000 (manually, in PROPERTIES window, not with VBA code) and it works correctly. So the problem is that I can't change the type of the "top" parameter.

    I hope you have some idea :-)

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Where are the variable declarations?

    PS Is there a reason why you aren't using Access?

    What you are trying to do could be set up in minutes using a continuous form.

    Each client's data would be in it's own form which you would be the equivalent of a frame.

    You would also have access to all the, built-in, search and filter functionality that Access offers.

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,001

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    How is genForms declared?

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645
    Try flipping the calculation.
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    06-13-2013
    Location
    Katowice
    MS-Off Ver
    Office 2007
    Posts
    19

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Dear Norie,
    Like I said - thank you for your commitment and contribution in my project, but I should be the one in this topic to ask questions. But for clarification:
    1. Variable declarations are on the top of the code, which is quite long (both file and the list of declarations),
    2. Yes, there is. I know how to prepare user form in EXCEL, but unfortunately I couldn't start to prepare forms because of lack of the tools to pick up labels, textboxes and so.
    3. Not everyone in my company has access installed. But this is the second reason why I do it in excel. The first one is the above one.
    4. I don't care about access search tools. They are easy to do in excel which I already know. As I said in point '2'.
    5. some other stuff ......

    Is any of my above explanations helpful for solving my problem?

  12. #12
    Registered User
    Join Date
    06-13-2013
    Location
    Katowice
    MS-Off Ver
    Office 2007
    Posts
    19

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Quote Originally Posted by Norie View Post
    Try flipping the calculation.
    Please Login or Register  to view this content.
    Unfortunately it doesn't helped.

  13. #13
    Registered User
    Join Date
    06-13-2013
    Location
    Katowice
    MS-Off Ver
    Office 2007
    Posts
    19

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Quote Originally Posted by romperstomper View Post
    How is genForms declared?
    Please Login or Register  to view this content.
    but 'genForms' stands for "generate forms" and this number is nearly 1200, so there's no way to be even close to Integer limit. The problem is with ".top" value and "scrollHeight" which generate "overflow" error when the value reaches 32767.

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    1 Can we see the declarations, specifically of the variables in the code you posted?

    (PS Sorry for the question)

    2 There are wizards in Access that will build the form for you.

    3 That would be a problem, but not insurmountable.

    4 In some ways Access search tools are far better than anything Excel has.

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    This might be the problem.
    Please Login or Register  to view this content.
    Try changing Integer to Long.

    PS Sorry for another question, where's the code that adds the frames?

  16. #16
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    I find your tone off, and doesn't really help your cause - everyone helps for free here and Norie's questions were relevant; I suspect your issue is one of implicit variable casting, try the below:
    Please Login or Register  to view this content.

  17. #17
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,001

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Changing the declaration to Long should fix it. I also agree wholeheartedly with Kyle's last comment.

  18. #18
    Registered User
    Join Date
    06-13-2013
    Location
    Katowice
    MS-Off Ver
    Office 2007
    Posts
    19

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    I can even give you the whole piece of code for this one window, but it's irrelevant for this solution, and there are many comments in strange (polish) language. It includes one time run option for importing data from excel to access. And ones again - it couldn't be done with access automate option because of different formats, improper values and so on, so there was much to do with those data:

    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    06-13-2013
    Location
    Katowice
    MS-Off Ver
    Office 2007
    Posts
    19

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    because of too many characters in my code I had to cut a big part of it, which is irrelevant to the problem.

  20. #20
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Change every declaration of Integer to Long.

  21. #21
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Did you read the suggestions? Top isn't the problem, the problem is that you are multiplying 2 integers, the result of which is out of bounds for an integer so you get an overflow error. To resolve it at least one number in the multiplication must be a long

  22. #22
    Registered User
    Join Date
    06-13-2013
    Location
    Katowice
    MS-Off Ver
    Office 2007
    Posts
    19

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Quote Originally Posted by Kyle123 View Post
    I find your tone off, and doesn't really help your cause - everyone helps for free here and Norie's questions were relevant; I suspect your issue is one of implicit variable casting, try the below:
    Please Login or Register  to view this content.


    THIS IS IT!! It helped.
    I didn't know this function cLng() for changing it to Long type. I also implemented it to the "scrollHeight" and now it work like expected.
    Sorry about my tone, but I didn't fine questions about "why in excel" helpful. Therefore I know the 'hidden reason' of those questions and I appreciate for your help. I hope I didn't offended anyone and thank you for spending your time on my issue.

  23. #23
    Registered User
    Join Date
    06-13-2013
    Location
    Katowice
    MS-Off Ver
    Office 2007
    Posts
    19

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Quote Originally Posted by Norie View Post
    Change every declaration of Integer to Long.
    Already did. Unfortunately (for me) I knew that I'm multiplicating integers, but I didn't know that two multiplicated integers gives also an integer. I hoped that the value will be automatically changed into 'Long', because I counld't find how I may change the type of '.top' variable.

    Thank you once again for your commitment :-) :-) . I got me very angry I couldn't find this answer by myself.

  24. #24
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    No problem.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  25. #25
    Registered User
    Join Date
    06-13-2013
    Location
    Katowice
    MS-Off Ver
    Office 2007
    Posts
    19

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Quote Originally Posted by Norie View Post
    This might be the problem.
    Please Login or Register  to view this content.
    Try changing Integer to Long.

    PS Sorry for another question, where's the code that adds the frames?
    Good question :-)
    This will be probably the topis of my next problem, but I'm trying to find it by myself since 5 days and I hope to find it. The general problem is, that the below code (already quoted above):

    Please Login or Register  to view this content.
    should generate frames. Because I couldn't find how to get rid of another error (excel hangs out on the line with creating frames) I change it to create buttons and it works:

    Please Login or Register  to view this content.
    if I change "FrameList.Controls.Add" (which should create those client frames in the main frame named: "FrameList") to "Me.Controls.Add" it works fine, but it draws those frames on the main user form, not inside this frame I created.

  26. #26
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    So when you change Forms.CommandButton.1 to Forms.Frame.1 it adds to the form, not the frame FrameList?

  27. #27
    Registered User
    Join Date
    06-13-2013
    Location
    Katowice
    MS-Off Ver
    Office 2007
    Posts
    19

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Quote Originally Posted by Norie View Post
    So when you change Forms.CommandButton.1 to Forms.Frame.1 it adds to the form, not the frame FrameList?
    No.
    changing "FrameList.Controls.Add("Forms.CommandButton.1")" to "FrameList.Controls.Add("Forms.Frame.1")" should generate frames in the bigger, 'main' frame called "FrameList", but instead of this it hangs the excel and it restarts (with the message, that it stoped working and it is lookding for solution).
    But if I change "FrameList.Controls.Add("Forms.Frame.1")" to "Me.Controls.Add("Forms.Frame.1")" it creates frames but in the main user form.

  28. #28
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Strange.

    I just ran this code and it worked fine.
    Please Login or Register  to view this content.
    That's all I had though, I'm sure you have much more going on.

    PS I tried with 1000 changed to 8000 and VBA really didn't like that especially when I tried to scroll after all the frames had eventually been added.

  29. #29
    Registered User
    Join Date
    06-13-2013
    Location
    Katowice
    MS-Off Ver
    Office 2007
    Posts
    19

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Wow...
    It really works! I can see what's going on, but I even didn't think that way! :-)

    Thank yoU!!

  30. #30
    Registered User
    Join Date
    06-13-2013
    Location
    Katowice
    MS-Off Ver
    Office 2007
    Posts
    19

    Re: userForm -> Frame 'top' value limited. Dynamically created controls,

    Now when I see how slow is my solution, I have to re-design my app and get rid of few of my ideas. Thank you for you help - it really show me the weak side of my idea.

+ 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. Using Class Module for handling events of dynamically created controls
    By jagman in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-17-2018, 01:14 PM
  2. Add MouseMove action to dynamically created form controls
    By AdLoki in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 03-19-2013, 09:09 AM
  3. Creating UserForm Controls dynamically
    By MWE in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-20-2005, 12:05 AM
  4. [SOLVED] Creating Userform Controls on Frame
    By David Myle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2005, 11:06 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