Solved

add labels at runtime, help !!

Posted on 2004-04-02
5
217 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now