Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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".
 
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

 
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


 
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


 
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?

 
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?





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





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