VBA

Moderators: PavlinII
Number of threads: 1673
Number of posts: 3078

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
new things Posted by Hadji_13 on 11 Feb 2003 at 3:36 PM
Hi

I want to add a new label to a form in access during run time, I then want to change the label.
Also I want to add a combo box with the list sourced from an SQL statment.

How do I add controls to a form in run-time? (in access)

I can probably do this in VB6, but with VBA I'm stuck

Cheers

Hadji
--------------------
Ying Tong Iddle I Po - Goons
Report
Re: new things Posted by VBNert on 14 Feb 2003 at 10:21 AM

: I can probably do this in VB6, but with VBA I'm stuck
Yes, you can do this in VB6. You have to make a control array, so in designing mode, you put in two labels with the same name. Then VB6 will ask you: "Do you want to create a control array?" then you click yes.
Then in the code of your project, put in this:

private sub lbl1_Click(index as integer)
load lbl1(index + 1)
lbl1(index + 1).top = 2000
lbl1(index + 1).left = 2000
lbl1(index + 1).caption = "Hello, I'm a new label"
end sub

maybe you need to put lbl1.show in this code, but I don't know, I'm not at home now, so I don't have VB at this computer.
If you click at lbl1(1) then this program will create a lbl1(2) at position (2000,2000) and with the caption "Hello, I'm a new label".
Make sure you check out how many of lbl1's there are, then you can put this code for example behind a command button.

Excuse me for my English, I'm dutch, so I don't speak English very well.

Hope you have success with this help.

Greetings,

VBNert
Report
Re: new things Posted by Hadji_13 on 14 Feb 2003 at 12:13 PM
Yes, I said I can do it in VB6, what I need is VBA code.
Any idea?

:
: : I can probably do this in VB6, but with VBA I'm stuck
: Yes, you can do this in VB6. You have to make a control array, so in designing mode, you put in two labels with the same name. Then VB6 will ask you: "Do you want to create a control array?" then you click yes.
: Then in the code of your project, put in this:
:
: private sub lbl1_Click(index as integer)
: load lbl1(index + 1)
: lbl1(index + 1).top = 2000
: lbl1(index + 1).left = 2000
: lbl1(index + 1).caption = "Hello, I'm a new label"
: end sub
:
: maybe you need to put lbl1.show in this code, but I don't know, I'm not at home now, so I don't have VB at this computer.
: If you click at lbl1(1) then this program will create a lbl1(2) at position (2000,2000) and with the caption "Hello, I'm a new label".
: Make sure you check out how many of lbl1's there are, then you can put this code for example behind a command button.
:
: Excuse me for my English, I'm dutch, so I don't speak English very well.
:
: Hope you have success with this help.
:
: Greetings,
:
: VBNert
:

----------------------------------------------------
The solution to the problem changes the problem




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.