Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 04-30-2006, 01:58 AM
vam vam is offline
Novice
 
Join Date: Apr 2006
Posts: 4
vam
Default dynamic textbox

how i can make a dynamic textbox at runtime using VBA

iam using access 2003

for ex:

when form open i want to create 10 textbox
Reply With Quote
  #2  
Old 06-04-2006, 06:59 AM
Novice
 
Join Date: Jun 2006
Location: USA
Posts: 6
mhartman
Default

Hello:

What you want to do is use the "CreateControl" method if you want to create controls dynamically when you need them.

Example
The following example first creates a new form based on an Orders table. It then uses the CreateControl method to create a text box control and an attached label control on the form.

Sub NewControls()
Dim frm As Form
Dim ctlLabel As Control, ctlText As Control
Dim intDataX As Integer, intDataY As Integer
Dim intLabelX As Integer, intLabelY As Integer

' Create new form with Orders table as its record source.
Set frm = CreateForm
frm.RecordSource = "Orders"
' Set positioning values for new controls.
intLabelX = 100
intLabelY = 100
intDataX = 1000
intDataY = 100
' Create unbound default-size text box in detail section.
Set ctlText = CreateControl(frm.Name, acTextBox, , "", "", _
intDataX, intDataY)
' Create child label control for text box.
Set ctlLabel = CreateControl(frm.Name, acLabel, , _
ctlText.Name, "NewLabel", intLabelX, intLabelY)
' Restore form.
DoCmd.Restore
End Sub
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
total in textbox micfly Access 3 11-09-2008 08:24 AM
Dynamic SQL Query Squeaner Queries 0 09-25-2008 12:37 PM
Textbox will not allow input cwf Forms 0 04-04-2008 02:08 PM
Dynamic Query Outer Join Problem mjack003 Queries 0 07-21-2006 11:07 AM
Report will not print a bound textbox vvrt Reports 0 03-16-2006 11:16 AM


All times are GMT -8. The time now is 10:16 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.