Apply One Event Procedure to Multiple Textboxes

Long time reader, first time poster. I have searched and searched for an answer to this question with no avail. So I thought I would ask.

What I have is a form with 21 sets of textboxes, each set represents an item. The goal is to have the item information populate in the other textboxes of that set after the item number has been updated. The boxes are named as follows txt_ItemNum_#, txt_Description_# where # is a number from 1 to 21 that identifies the set.

I can write the procedure and all, but I'm hoping there is a more efficient way than creating 21 seperate events

Sponsored Links:

Related Topics

Re-populate Subform textboxes on Mainform combobox update.
I have a combo box in a subform that [LINK] textboxes in the subform.

The subform combo box also has a Dlookup procedure on "after update" event that has a criteria on what the AutoFill procedure will populate based on the mainform textboxes that is AutoFilled by a mainform combo box.

Everything works fine, until I change the value of the Mainform combobox, which changes the value of the textboxes on the mainform from which the Subform combobox gets its criteria for the Dlookup procedure.

My problem is that the Subform combobox does not re-populates the subform textboxes when I change the value of the mainform combobox. I still need to select the same item in the subformcombobox list to initiate the AutoFill procedure of the subform textboxes.


Creating Event Procedures in Microsoft Access
If you need to automate an action from a single event of a control then you can write all of the necessary VBA code as an event procedure that is attached to the event property of that particular control. A procedure contains a series of Visual Basic statements that perform an operation or provide a calculation. An event procedure is a procedure that runs in response to an event initiated by the user or program code, or triggered by the system.


How to use a user written function as an event procedure
I have two fields on one form that will both use the same procedure on AfterUpdate for either field. Is there some way to assign this one procedure to both fields AfterUpdate events? I know about [Event Procedure], but I'm talking about a separate routine.
I have tried a function and a sub, but within the code module associated with the form, and I have tried both a function and a sub within a standard module, but none of these seem to work the way I'm doing it.
Of course, if this is not possible, I can have each [Event Procedure] call my own procedure, but I was hoping there was a way to just call my procedure from the Event tab in the properties window


How to use a user written function as an event procedure
I have two fields on one form that will both use the same procedure on AfterUpdate for either field. Is there some way to assign this one procedure to both fields AfterUpdate events? I know about [Event Procedure], but I'm talking about a separate routine.

I have tried a function and a sub, but within the code module associated with the form, and I have tried both a function and a sub within a standard module, but none of these seem to work the way I'm doing it.

Of course, I can have each [Event Procedure] call my own procedure, but I was hoping there was a way to just call my procedure from the Event tab in the properties window.


How to pass event parameter to a function without using [Event Procedure]?
For instance, I want to use a generic function =FormKeyDown() on form's key down event, instead of using event procedure:


Programmatically Add Event Procedure
I need to know how to add an event procedure to a form programmatically. I have a routine where a user generates a custom form & subforms for data input. I need to add event procedures to some of the subforms on the form that have been created with the code.

This all must be done with VBA and I do not have the option of making the event procedure the typical way because the form is created on the spot with


My Access database has lost all event functionality
I have been writing an Access 2010 database on Win7/64bit for the last couple of weeks and had all of the functions working well. I opened the file after vacation and now have no event functionality at all.
It seems like the file is no longer trusted and the functions are locked in some way, however I have checked the trusted files location and it is correct.

I get the following error message on every event that runs:

The expression On (all events) you entered as the event property setting produced the following error: Procedure declaration does not match description of event or procedure having the same name.
* The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]
* There may have been an error evaluating the function, event, or macro.


Cancel an Event
Under some circumstances, you may want to include code in an event procedure that cancels the associated event. For example, you may want to include code that cancels the Open event in an Open event procedure for a form, preventing the form from opening if certain conditions are not met.
This tutorial lists the events that can be canceled programmatically.


OpenModule Macro Action
You can use the OpenModule action to open a specified Visual Basic for Applications (VBA) module at a specified procedure. This can be a Sub procedure, a Function procedure, or an event procedure.


runtime error 2448
I have a form which allows user to enter new details in a site. The thing is when the user opens the form all the textboxes should be empty and be ready for the user to enter details. Therefore, I put an event procedure in Onopen or onload to initalise all the textboxes to be empty, ( one example textbox shown below)
Me.SiteName.Value = " "

it gives me a runtime error 2448 - saying that this object cannot be assigned. I m not sure what the problem is. However when I put the same code behind a button, it works perfectly!


VBA AfterUpdate Event Procedure
I think event procedure for normal combo box and multiple-value-select combo box is different. I have 'station' and 'language' combo boxes. Both are multi-value-select combo boxes. This means that more than one item can be selected from the drop down list.

When the value of 'station' combo box is 'Nationwide', then I want that all values on the combo box list in 'Language' field is automatically selected.

How should I write the after update procedure? I have been having fun with it for the last two days.


AfterUpdate Event Procedure
I think event procedure for normal combo box and multiple-value-select combo box is different. I have 'station' and 'language' combo boxes. Both are multi-value-select combo boxes. This means that more than one item can be selected from the drop down list.

When the value of 'station' combo box is 'Nationwide', then I want that all values on the combo box list in 'Language' field is automatically selected.

How should I write the after update procedure? I have been having fun with it for the last two days


Event doesn't happen
I have created a small db with a form. I'd like maximize the form when is started. So on the "On Load" form Event property I have putted the command

DoCmd.Maximize

but when the form is loaded the on load sub procedure isn't called. I have tried to put a breakpoint in the sub. None form event procedure isn't called. I have just enabled Macro VBA procedure


onDirty Code
Embedded within the OnDirty Event of the form, so that when there is a change in form details the command button is enabled, however I seem to receive this error message when making an entry into a field

'The expression onDirty you entered as the event property setting produced the following error:
Procedure declaration does not match description of event or procedure having the same name'


Bypass startup options when you open a database
If you used the Access Options dialog box, created an AutoExec macro, or created an Open event procedure (event procedure: A procedure that is automatically executed in response to an event initiated by the user or program code, or that is triggered by the system.) to specify what happens when you open a Microsoft Office Access database, you can bypass those settings to regain full access to your database.
What do you want to do?
* Bypass startup options
* View bypassed options


Event Procedure on Closing a Form
was wondering what event procedure I could possibly use to automaticaly save a forms data when the user closes the form using the 'x' at the top right of the screen, would that be 'on unload' or is there something else I need to use


Stopping an event procedure
Can anyone tell what the code is for stopping an event procedure? I'm trying know to stop a combo box's exit from running using the mousemove event over a different combo box


Calling fields into VBA Private Sub
I've placed a button in a form and in the Property Sheet, Event, On Click I've selected Event Procedure.
I've tried a simple routine with just a MsgBox, that goes:

Private Sub NewReg_Click()
MsgBox ("hello") End Sub

When I click the button in the Form View, it works and the messege appears. But I want the procedure to operate with some fields that I entry in the form. When I try to call a field of the form in the routine:

Private Sub NewReg_Click(Num_Entries)
MsgBox ("hello") End Sub

I get the following error when I click the button:

procedure declaration does not match description of event or procedure having the same name


HowEliminate"EmbeddeMacro"?
When I use Wizards for making a command Button in a from , Access uses Embedded Macro automatically, instead of Event procedure. I checked "always use event procedures" option in the Access Options ( Access Options--> Object Designers --> form-Report design view -- > always use event procedures ) . But Access use "Embedded Macro" yet. How can I force Access to use Event procedure


Sum in Footer on Form with ADO Recordset
Why would Sum(fieldname) not work in a form based on an ADO Recordset drawing from a Stored Procedure?

I had a form with a DAO query from linked tables as its RecordSource. Textboxes in the footer showed the Sum for various fields.

When I changed the form to use an ADODB Recordset based on a Stored Procedure in MS SQL Server 2005 the Sum textboxes return Error. There were no other significant changes to the form.

There are certainly other ways to get the Sum but I wonder why it doesn't work the same as the Recordset coming from the DAO RecordSource