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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call Update method in VBA

Status
Not open for further replies.

sogibear

Programmer
Jul 4, 2002
45
GB
Does anyone know how to force a control to run it 'Updated' method in vba ?

Thanks
 
Hello, i was being a bit lazy last time.

basically i've got an Unbound form, with a name field. I've also got a validation rule for name in the properties section on the form, stopping it from accepting zero length strings values.

Here's the thing :
if you open the form, leave the name field blank and click save, it saves !! This is NOT good.

However:
If you open the form, type some data into the field, then delete it ALL, then click save, it will fire the validation rule ?? Weird !!
:)
 
Actually, it's not weird at all. It's exactly the way Access was designed, and exactly the way it's described in the documentation. What's happening is that the event doesn't fire unless you update the control. That's why it's called the AfterUpdate event.

There are a few ways to deal with this. The one that makes the most sense to me is to put the code you want to run in a function in the form's module. Then you can call that function from both the AfterUpdate of the control and the AfterUpdate of the form. Actually, though, you might want to use the BeforeUpdate, so that you can cancel the event, if the function returns an appropriate value (such as False).

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top