Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Event not firing

Status
Not open for further replies.

MasterRacker

New member
Oct 13, 1999
3,343
0
0
US
Access 2007. I have a subform with 3 textboxes: Value, Quantity, Total.

I also have a combo box to choose an item. When an item is chosen, a dlookup will find the value and populate the Value box and set focus to Value. All pretty basic stuff. Value and Quantity both have AfterUpdate events to call a function to calculate the total by multiplying them together.

The problem is when the combo populates the value and I tab out of it, the AfterUpdate does not fire and the total is not updated. If I type in a value and tab out, everything updates correctly.

What might be preventing the event from firing? Is there a way in VBA to manually fire an event?

Is VBA populated data buffered in the form and not committed the same way as typed info?

Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
 
When you populate a control with VBA the AfterUpdate event isn't fired.
 
PHV - that explains it.
PWise - Lost focus is a good choice. Does what I need.
Thanks.

Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
 

After populating the control with VBA you could simply Call the AfterUpdate event.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Yeah, that sounds like an option too. I like the LostFocus event in this case though because I have one event to handle both VBA and manual population.

Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
 
So would the AfterUpdate event! Using the LostFocus event, your code will fire every time you tab thru the field, even if you do nothing! And what happens with your code if the user tabs thru it and it has no value, i.e. is Null? Nulls break a lot of code!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
I would advise never calling an Event directly. It confuses what action actually initiates the code, and can add complexity to debugging. Better to create a subroutine that does the action, and have it called from both the Event and whereever else it is supposed to happen.
 
How are are ya MasterRacker . . .

My read saids you have what you need.
MasterRacker said:
[blue]Value and Quantity [purple]both have AfterUpdate events to call a function to calculate the total by multiplying them together.[/purple][/blue]
Why not simply call this function in your combobox code! ... this is what [blue]JoeAtWork[/blue] is relating to ...

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
That value that's populated is only a suggested value. It can also be overridden by typing a new value so I still need an event on the value box. In addition, the combo box is not restricted to values on the list. I can also enter values manually if they are not on the list, in which case the value has to be manually entered. Values are defaulted to 0 so there is no worry about nulls. I realize that tabbing thru an existing row fires update unnecessarily, but it is not a problem in this case.

For my purposes, this is working perfectly.

Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
 
MasterRacker . . .

You stated:
MasterRacker said:
[blue]The problem is when the combo populates the value and I tab out of it, [purple]the AfterUpdate does not fire and the total is not updated[/purple].[/blue]
Does not my suggestion at the very least ... solve this issue with the combobox? [surprise] ... Other Problems are what they are and may need to be handled as such.

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
AceMan1 - I think I need more details. I have a combobox with a data source that is not is not limited to the list. What combobox code is there beside event functions?

If you mean having only one Calculate function, I do. The comboboxs LostFocus calls Calculate as do Value.AfterUpdate and Qty.AfterUpdate.

Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top