Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > BOOK: Access 2003 VBA Programmer's Reference
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Access 2003 VBA Programmer's Reference
This is the forum to discuss the Wrox book Access 2003 VBA Programmer's Reference by Patricia Cardoza, Teresa Hennig, Graham Seach, Armen Stein; ISBN: 9780764559037
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2003 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 10th, 2006, 04:39 AM
Registered User
 
Join Date: Jan 2006
Location: , , Switzerland.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access 2003 - Adding Textbox at runtime?

I would like to add textboxes at runtime in Access 2003. Is it possible ? Can someone provide me with the code ?
I have added runtime controls in VB6, but somehow when I try to add controls in VBA with Access 2003, it gives me Error "Activex Component can't create object".
Reply With Quote
  #2 (permalink)  
Old January 29th, 2006, 07:40 PM
Authorized User
 
Join Date: May 2004
Location: montpellier, 34000, France.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi
try to read again the book if you possess one. i think that i have red it somewhere in the book. or you can goto the help topic from access or VBA and search for controls collection or
try this in your code!

    Dim ctls As Controls
    Set ctls = Me.Controls
    ctls.Application.CreateControl ()
it depends on if you want to save the control or not. if you use this control at run-time and discard it later. you can create a control then hide it. set the visible property to true if you want to show it.
hope this helps

Reply With Quote
  #3 (permalink)  
Old January 29th, 2006, 07:45 PM
Authorized User
 
Join Date: May 2004
Location: montpellier, 34000, France.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

sorry, i have made an error
you dont have to do

    dim ctls as controls
    set ctls = me.controls

but

    dim ctl as control
    set ctl = application.createcontrol ("...","...")
for example


Reply With Quote
  #4 (permalink)  
Old January 29th, 2006, 07:48 PM
Authorized User
 
Join Date: May 2004
Location: montpellier, 34000, France.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this is an example from VBA code
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
  #5 (permalink)  
Old February 14th, 2006, 11:23 AM
Registered User
 
Join Date: Feb 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

... but these commands only allow you to create a control in DESIGN view mode. Is there any way to create a control at runtime?

Reply With Quote
  #6 (permalink)  
Old February 17th, 2006, 01:18 PM
Authorized User
 
Join Date: May 2004
Location: montpellier, 34000, France.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

use docmd.echo ON/OFF to freeze the screen and switch the form from normal view to design view then add the controls and save the form. reopen the form in normal view.
or you can hide and show the controls at runtime. it depends on what you want!
designing form or entering data?

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding button at runtime ehabinl BOOK: Professional C#, 2nd and 3rd Editions 0 August 7th, 2006 03:48 AM
.mde on 2003 runtime problems johnny_utah Access 1 April 17th, 2006 10:23 PM
Run Microsoft Access 2003 with runtime C_O Access 2 February 17th, 2006 01:36 PM
Access 2003 Runtime Clarence Morgan Access 1 December 3rd, 2004 01:23 AM
Adding new record in Access 2003 adp subform rayo Access 1 September 4th, 2004 04:41 PM



All times are GMT -4. The time now is 06:54 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.