+ Reply to Thread
Results 1 to 30 of 30

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

Hybrid View

  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
    21,998

    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:

    'generate new controls - frames, labels, buttons and so on.
    For genForms = 1 To NumberOfClients 'NumberOfClients
        Set genFrame = FrameList.Controls.Add("Forms.CommandButton.1")
    With genFrame
    .Name = "claim" & genForms
    .Caption = "nr " & genForms
    .Top = (40 * genForms) - 40
    .Left = 0
    .Height = 40
    .Width = 988
    End With
    Next genForms
    FrameList.ScrollHeight = genForms * 40
    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
    21,998

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

    How is genForms declared?

  10. #10
    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?
    Dim genForms As Integer
    Dim genFrame As Object
    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.

  11. #11
    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.
    .Top = (genForms * 40) - 40

  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.
    .Top = (genForms * 40) - 40
    Unfortunately it doesn't helped.

  13. #13
    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.
    Dim genForms As Integer
    Try changing Integer to Long.

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

  14. #14
    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.
    Dim genForms As Integer
    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):

    'generate new controls - frames, labels, buttons and so on.
    For genForms = 1 To NumberOfClients 'NumberOfClients
        Set genFrame = FrameList.Controls.Add("Forms.CommandButton.1")
    With genFrame
    .Name = "claim" & genForms
    .Caption = "nr " & genForms
    .Top = (40 * genForms) - 40
    .Left = 0
    .Height = 40
    .Width = 988
    End With
    Next genForms
    FrameList.ScrollHeight = genForms * 40
    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:

    Set genFrame = FrameList.Controls.Add("Forms.Frame.1")
    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.

  15. #15
    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?

  16. #16
    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.

  17. #17
    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:
    .Top = (clng(40) * clng(genForms)) - 40

  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,

    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:
    .Top = (clng(40) * clng(genForms)) - 40


    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.

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

    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.

  20. #20
    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:

    Option Explicit
    
    Dim computerName As String
    Dim userName As String
    Dim databaseLocation As String
    Dim fileWithDatabase As String
    Dim currentWorkbook As String
    Dim dataSheet As String
    Dim rs As New ADODB.Recordset
    Dim connDB As New ADODB.Connection
    Dim strSQL As String
    Dim NumberOfClaims As Integer
    Dim LiczbaWierszyWPliku As Integer 'import
    Dim importName As String 'import
    Dim xlSourceApp As New Excel.Application 'import
    Dim sourceWb As Workbook 'import
    
    Dim doClip As DataObject
    Dim zakladka As String 'import
    Dim daneDoImportu() As String 'import
    Dim iImport As Integer 'import
    Dim iKolumna As Integer 'import
    Dim iEksport As Integer 'import
    Dim importSQL As String 'import
    Dim ubezpString() As String 'import
    Dim poszkString() As String 'import
    Dim adresSzkodyString() As String 'import
    Dim i As Integer ' import
    Dim adresZeStringa As String 'import
    Dim azs As Integer 'import (do powyższego stringa)
    
    Dim tempDate As String 'import
    Dim nrSzkody As String 'import
    Dim nrFufi As String 'import
    Dim nrPolisy As String 'import
    Dim ochrOd As Variant 'import
    Dim ochrDo As Variant 'import
    Dim agentNr As String 'import
    Dim agentNazw As String 'import
    Dim koordNr As String 'import
    Dim koordNazw As String 'import
    Dim ubezpNazw As String 'import
    Dim ubezpAdres As String 'import
    Dim ubezpTel As String 'import
    Dim poszkNazw As String 'import
    Dim poszkAdres As String 'import
    Dim poszkTel As String 'import
    Dim zglaszajacySzkode As String 'import
    Dim szkodaPowst As Variant 'import
    Dim szkodaUjaw As Variant 'import
    Dim szkodaZglo As Variant 'import
    Dim szkodaAdres As String 'import
    Dim przedmUbezp As String 'import
    Dim klauzula As String 'import
    Dim ryzyko As String 'import
    Dim klasaRach As String 'import
    Dim grupaUbezp As String 'import
    Dim opisSzkody As String 'import
    Dim przyczSzkody As String 'import
    Dim rezerwa As Double 'import
    Dim rezerwaTechn As Double 'import
    Dim likwProw As String 'import
    Dim dataWyplOdm As Variant 'import
    Dim status As String 'import
    Dim kwotaWypl As Double 'import
    Dim rezerwaAkt As Double 'import
    Dim rozwiazaneRezerwy As Double 'import
    Dim kosztyTechnDataWypl As Variant 'import
    Dim kosztyTechnKwota As Double 'import
    Dim regres As String 'import
    Dim uwagi As String 'import
    Dim rejestrujacy As String 'import
    Dim dataRejestracji As Variant 'import
    Dim IPkomputera As String 'import
    
    Dim genForms As Integer
    Dim genFrame As Object
    
    Private Sub btnNewClaim_Click()
    FormRegisterClaim.Show
    End Sub
    
    Private Sub CommandButton1_Click()
    
    'liczenie ilości szkód w istniejącym rejestrze szkód
    importName = Application.GetOpenFilename("Excel Workbooks (*.xls*), *.xls*")
    zakladka = "REJESTR SZKÓD"
    Set xlSourceApp = GetObject(, "Excel.Application")
    Set sourceWb = xlSourceApp.Workbooks.Open(importName)
    LiczbaWierszyWPliku = sourceWb.Worksheets(zakladka).Range("C1", Range("C1").End(xlDown)).Count 'liczenie liczby szkód (odliczony nagłówek)
    
    'sczytywanie danych z excela do tablicy, a potem eksport do accessa
    ReDim daneDoImportu(LiczbaWierszyWPliku - 1, 33)
    
    iImport = 0
    iKolumna = 0
    'przeniesienie danych do tablicy
    For iImport = 2 To LiczbaWierszyWPliku
        For iKolumna = 1 To 33
            daneDoImportu(iImport - 1, iKolumna) = sourceWb.Worksheets(zakladka).Cells(iImport, iKolumna)
        Next iKolumna
    Next iImport
    
    sourceWb.Close SaveChanges:=False
    Set xlSourceApp = Nothing
    
    iEksport = 0
    iKolumna = 0
    'przeniesienie danych do accessa
    
    [cut]
    MsgBox ("export done")
    
    End Sub
    
    Private Sub UserForm_Initialize() 'inicjalizacja formularza - ustawienie i sprawdzenie danych
    GetEnvData
    If userName = "john" Or userName = "mark" Or userName = "ana" Then 'funkcja dostępna tylko dla "adminów"
        MultiPage.Page2.Visible = True
        GenerateClaimList
        Else
        MultiPage.Page2.Visible = False
    End If
    
    textbox_database.Text = databaseLocation ' pole z linkiem do pliku bazodanowego
    
    CheckDatabaseConnection (databaseLocation)
    
    End Sub
    
    Private Sub GenerateClaimList()
    strSQL = "SELECT COUNT(*) as NoClaims FROM SZKODY"
    ConnectDB (databaseLocation)
    Set rs = connDB.Execute(strSQL)
    NumberOfClaims = rs!NoClaims
    DisconnectDB
    
    'MsgBox (NumberOfClaims)
    
    'generate new controls - frames, labels, buttons and so on.
    For genForms = 1 To 2000 'NumberOfClaims
        Set genFrame = FrameListaSzkod.Controls.Add("Forms.CommandButton.1")
    With genFrame
    .Name = "claim" & genForms
    .Caption = "nr " & genForms
    .Top = (genForms * 40) - 40
    .Left = 0
    .Height = 40
    .Width = 988
    End With
    Next genForms
    FrameListaSzkod.ScrollHeight = genForms * 40
    
    End Sub
    
    Private Sub UserForm_Terminate()
    DisconnectDB
    End Sub
    
    
    Sub GetEnvData() 'pobranie (ustawienie) zmiennych środowiskowych wymaganych do pracy programu
    computerName = Environ$("computername")
    userName = Environ$("username")
    currentWorkbook = ThisWorkbook.Path & "\" & ThisWorkbook.Name
    dataSheet = "envData"
    databaseLocation = Sheets(dataSheet).Cells(2, 1)
    End Sub
    
    
    Private Sub ConnectDB(dbLocation)
    connDB.Open ConnectionString:="Provider = Microsoft.ACE.OLEDB.12.0;  Persist Security Info = False; data source=" & dbLocation & ";"
    Set rs = New ADODB.Recordset
    'rs.Open Source:="szkody", ActiveConnection:=connDB, CursorType:=adOpenStatic, LockType:=adLockOptimistic
    
    
    End Sub
    
    Private Sub DisconnectDB()
    'close the objects (jeśli istnieją)
    If rs.State = 1 Then
        rs.Close
        connDB.Close
    End If
    'destroy the variables
    Set rs = Nothing
    Set connDB = Nothing
    
    End Sub
    
    Private Sub btn_acceptDatabase_Click() 'potwierdzenie (zapisanie) lokalizacji pliku bazodanowego
    Worksheets(dataSheet).Range("A2").Value = textbox_database.Text
    ThisWorkbook.Save 'SaveChanges:=True
    CheckDatabaseConnection (databaseLocation)
    End Sub
    
    Private Sub btnSelectDatabase_Click() 'wybranie pliku bazodanowego z eksploratora windows
    fileWithDatabase = Application.GetOpenFilename("Excel Workbooks (*.accdb*), *.accdb*")
    textbox_database.Text = fileWithDatabase
    If textbox_database.Text <> "False" Then
    btn_acceptDatabase.Visible = True
    Else
    btn_acceptDatabase.Visible = False
    End If
    databaseLocation = fileWithDatabase
    End Sub
    
    Private Sub CheckDatabaseConnection(dbLoc) ' sprawdzenie, czy plik bazodanowy ACCESS istnieje.
    If Dir(dbLoc) <> "" Then
        lblDbStatus.Caption = "OK"
        lblDbStatus.BackColor = RGB(0, 200, 0)
        lblDbStatus.ForeColor = RGB(0, 0, 0)
        frameClaims.Visible = True
        ConnectDB (dbLoc)
    Else
        lblDbStatus.Caption = "BŁĄD!"
        lblDbStatus.BackColor = RGB(255, 0, 0)
        lblDbStatus.ForeColor = RGB(255, 255, 255)
        frameClaims.Visible = False
    End If
    End Sub

  21. #21
    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.

  22. #22
    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.

  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 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

  25. #25
    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.

  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.
    Dim frm As MSForms.Frame
    Dim frmParent As MSForms.Frame
    Dim I As Long
    
        Set frmParent = Me.Frame1
    
        For I = 1 To 1000
    
            Set frm = frmParent.Controls.Add("Forms.Frame.1")
    
            With frm
                .Name = "claim" & I
                .Caption = "nr " & I
                .Top = (40& * I) - 40
                .Left = 5
                .Height = 40
                .Width = frmParent.Width - 20
            End With
    
        Next I
        
        frmParent.ScrollHeight = I * 40
    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