Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

add labels at runtime, help !!

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Progress
Screencast - Getting to Know the Pipeline

879 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