Topics Search

Apply One Event Procedure to Multiple Textboxes

Apply One Event Procedure to Multiple Textboxes
Views: 111
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:

Similar posts...


Re-populate Subform textboxes on Mainform combobox update.

Re-populate Subform textboxes on Mainform combobox update. Icon
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

Creating Event Procedures in Microsoft Access Icon
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

How to use a user written function as an event procedure Icon
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 pass event parameter to a function without using [Event Procedure]?

How to pass event parameter to a function without using [Event Procedure]? Icon
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

Programmatically Add Event Procedure Icon
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

My Access database has lost all event functionality Icon
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

Cancel an Event Icon
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

OpenModule Macro Action Icon
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

runtime error 2448 Icon
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

VBA AfterUpdate Event Procedure Icon
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.