How to inherit a VBA form?

Asked

Viewed 156 times

2

I need to inherit a form in a VBA to use it as a basis for other forms.

For example, a form called "Table" contains a list of two columns and buttons for 'Edit', 'Include' and 'Rule out' the items; and whenever you make use of tables in the project this form should serve as a basis, but can make implementations in each case:

Tabulation: will contain the Acronym of each state and its Description, using as a basis the form Table unchanged.

Tabletaxadedelivery: will contain the Acronym of the state, its respective Description (which shall use data from Tabulation, what is an implementation on the form Table original), the Neighborhood (a simple description) and the Valor of the delivery fee, also using the form Table as a basis but with two new columns to be created in addition to the two existing in the original (total of four columns for data).

The idea is to be able to make changes to the form Table that would be taken over by the forms that are based on it, for example, including a button 'Helping' which will be common to all and assumed automatically, without having to include this form-by-form button.

Can do?

  • I found your question very interesting, but I’m not going to answer because I really don’t know. I took a quick look at my Excel here (2010 version) and there doesn’t seem to be a native way to do what you want (because every userform is independent and you don’t even have direct access to his class). It also doesn’t seem possible to simply copy and paste an existing form. Thus, an idea that I would evaluate is to write code to generate new forms automatically from an existing one. Continue...

  • 2

    Thus, it may be possible to write a code that evaluates a "base form" and creates an equal copy (a new one, for you to manually manipulate), and that also compares with another existing form to automatically add only components that do not exist (the new components). It shall be possible. Suggested reading: https://support.microsoft.com/en-us/kb/204330

  • 1

    Luiz, thanks for the tip. Your question is also interesting I suggest you do on the site (like copy and paste forms), because I know how to answer and I think it will be useful for many people.

  • Hi Leo. You can ask the question yourself. When you ask a question, there is the possibility to mark a checkbox and answer it yourself. :)

  • Luiz, I tried in several ways to execute the examples of the link you indicated, but in all cases they gave error. Please, could you generate an example? If this is the case I have a new question for this, but with this example, I believe it serves as an "answer" because I have no other way of doing it.

  • "but in all cases they gave error" -> What error? I could, if I had time (lately it is difficult). Ideally you try to make a [mcve] and open a new question about such an error.

  • 1

    Ok, I created the question: How to create forms dynamically in VBA?

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.