Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

creating text boxes in code

Posted on 2003-03-08
8
Medium Priority
?
138 Views
Last Modified: 2010-05-01
im sure this is easy, if it isn't please advise me and i will regrade it.

I have two forms,  "form 1" contains a list box, with a variable number of items in it.
I need to create labels and list boxes for each of those items in "form 2" when i click on the command button in "form 1".  

Please help, none of my books give me the commands, and i have scrolled through about 5000 answers on here.
0
Comment
Question by:irishboyx
8 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 8093866
0
 
LVL 4

Expert Comment

by:SSSoftware
ID: 8093957
Irishboy:

An easier way to add controls to a form dynamically is to use a control array.

It does require a little coding though:

1) add a prototype control to your form
2) set the index property to 0 (zero)
3) Code the evente that you need to use (Use the Index parameter to identify the control that caused the event)

When you need to add a new control then you

1) Load ControlName(New_Index_Number)
' the indexnumber of the control must not currently exist
2) Position the control where you want it
3) set the visiblew property to true

You can now use all the events that you created for the
control with the zero index.

Note that the first parameter is the index number of the control that caused the event.

To remove the controls you use the UNLOAD function

Good Luck,
Ed
0
 
LVL 2

Expert Comment

by:spauljoseph
ID: 8094191
Step 1:  Place a Label and TextBox in the Form2
Step 2:  Set 0 in the Index Property of those Lable and TextBox controls
Step 3:  Write the following code in the Command Button Click event of Form1



Private Sub Command1_Click()
    Dim lngCnt as Long

    With Form2
        .Label1(0).Caption = "List 1"
        .Text1(0).Text = List1.List(0)
        For lngCnt = 1 to List1.ListCount - 1
             Load .Label1(lngCnt)
             .Label1(lngCnt).Caption = "List " & lngCnt + 1
             .Label1(lngCnt).Move .Label1(lngCnt-1).Top + .Label1(lngCnt-1).Height + 120
             .Label1(lngCnt).Visible = True
             Load .Text1(lngCnt)
             .Text1(lngCnt).Text = List1.List(lngCnt)
             .Text1(lngCnt).Move .Text1(lngCnt-1).Top + .Text1(lngCnt-1).Height + 120
             .Text1(lngCnt).Visible = True
        Next
    End With
End Sub
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:CleanupPing
ID: 8900474
irishboyx:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9074465
irishboyx, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Save as PAQ -- No Refund.

DanRollins -- EE database cleanup volunteer
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 9075313
My recommandation: split between emoreau and SSSoftware
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9165932
Without feedback from asker, it is hard to tell who is correct. Question is PAQ'd and no points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 9166424
Why didn't you follow my recommandation?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question