Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

add labels at runtime, help !!

Posted on 2004-04-02
5
Medium Priority
?
224 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 1000 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 1000 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

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?
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Simple Linear Regression
Progress

705 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