Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 November 15th, 2006, 11:16 PM
Authorized User
 
Join Date: Oct 2006
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default Set/Assign an Event to textbox from Code

I am creating text boxes on a form programatically. This allows me to name all the controls how I want them named from vba, avoiding the 'one at a time' method, and also lets me rebuild the form entirely from scratch in an instant.

My question is once I have created an individual textbox and assigned properties as follows ....

 Set ctlText = CreateControl(frm.Name, acTextBox, acFooter, "", "", _
    intPositionX, intPositionY, AmtTextWidth, AllTextHeight)
    ctlText.Name = "TotalPallets"
    ctlText.BackColor = 65280

[u]Can I add then </u>assign either a macro or the function to the textbox as the next line of code, as follows (except this doesn't seem to work)

    ctlText.AfterUpdate = "=GetProductAmounts()"

which assigns the function directly, or...

    ctlText.AfterUpdate = "GetOrderTotal"

which assigns the macro. If I do the latter manually in the properties AfterUpdate Event it does work, so I know the macro is working. But when I attempt to set it from code the event property doesn't get filled. What am I doing wrong?






Similar Threads
Thread Thread Starter Forum Replies Last Post
TextBox Event davewoods Visual Basic 2005 Basics 3 October 10th, 2008 12:56 PM
assign report permissions thru vb .net code polofson Reporting Services 0 April 15th, 2008 05:31 PM
how do i assign keypress event on F2 kau_shuk VS.NET 2002/2003 1 August 25th, 2006 08:49 PM
enter key on textbox, performs button event code?? squeakstar Visual Basic 2005 Basics 4 June 22nd, 2006 05:13 AM
How to assign dynamic value to textbox in struts JasmineStanly JSP Basics 0 August 22nd, 2005 03:56 AM





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