Solved

add labels at runtime, help !!

Posted on 2004-04-02
5
222 Views
Last Modified: 2010-04-17
this code does not work in access vba, help.  please be explicit in codde examples, eg declarations and all, thanx. very much.




Dim ctlName As Control  ' in declaration section

Private Sub Command1_Click()


Set ctlName = Form1.Controls.Add("VB.TextBox", "Text1", Form1)

ctlName.Visible = True

ctlName.Top = Check1(0).Top + Check1(0).Height

End Sub
0
Comment
Question by:vbsterxx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
jjafferr earned 250 total points
ID: 10746138
Hi vbsterxx,
try putting your delaration line, below the Private sub

Private Sub Command1_Click()
Dim ctlName As Control  ' in declaration section

Hope this helps

jaffer
0
 
LVL 2

Assisted Solution

by:rqs
rqs earned 250 total points
ID: 10747326
I've tried this on access 2000:

Private sub cmdNewControl_Click()
   Dim ctlnewbutton as Control
   Dim frmnewform as Form
   
   Set frmnewform = CreateForm()
   frmnewform.Visible = False
   Set ctlnewbutton = CreateControl(frmnewform.name, acTextBox, acDetail)

   With ctlnewbutton
       .Width = 1000
       .Height = 200
       .Left = 200
       .Top = 200
       .Name = "txtNewControl"
   End With

   DoCmd.Close acForm, frmnewform.Name, acSaveYes
End Sub

There's a catch, Access doesn't allow creation of new controls on an open form
when that particular form is not open in design view.
That's why in the code above, the control was created on another new form.
You can then attach this new form as a subform on your target form
0
 
LVL 2

Expert Comment

by:rqs
ID: 10747332
i've found a related post here, go check it out:
http://oldlook.experts-exchange.com:8080/Databases/MS_Access/Q_20726109.html
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

734 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