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

AfterUpdate to update a field 1

Status
Not open for further replies.

hceonetman

Technical User
Mar 16, 2001
92
US
This seems a very basic function in Access, but I can't get it to work right. I have a form and subform, both from tables with a one-many rela. In the subform there are two fields, footage and mileage. I want the user to be able to update either field and the subform to then calculate the other, that is, user enters footage 5280, mileage field should be set to 1 and display as such. Or vice versa.
I set the afterupdate property of the footage field to call a macro which does 'SetValue' of me!mileage to Round([me]![Footage]/5280,2). When I enter a value in the footage field I get the error "The object doesn't contain the Automation ofject 'Me'". It says to check the component's documentation for info on the properties and methods it makes available for automation operations. What exactly are they trying to say?

Thank you.
If all else fails, I may have to read the manual.
 
Rather than using Me! reference the form explicitly

Forms!MyForm!Footage

If you want to use Me! do it in vba. "The Key, The Whole Key, and Nothing But The Key, So Help Me Codd!"
 
In the After Update of footage I'd simply put

Me!Mileage = (Me!Footeage / 5280)

Then set the Decimal Places property of Footage to 2.

HTH

Chris
 
Krispi, 930Driver;
When I put the equation directly on the line for AfterUpdate, and then modify a footage amount I get the error 'MS Access can't find the macro' followed by the equation. It thinks I'm entering the name of a macro. Referring to the forms controls didn't work either. I now have it as a VB expression in the AfterUpdate property, and it seems to be working. I'm not sure why it didn't work as a macro or entered directly on the line.

The mysteries of Access are many and deep. I'm sure I'll be back here with more questions.

Thank you,
HCEONETMAN



 
Click on the three dots icon to the right of the 'After Update' event. When the 'Choose Builder' box pops up, select'Code Builder'. Then type the text directly into the class module.

When you have finished you should see the words [Event Procedure] in your field's After Update event.

Chris
 
Krispi,
Thanks again. I followed your instructions exactly to do the reverse (user enters mileage, calculate footage) and it worked perfectly.

I guess my mistake was trying to use a macro to update. Once I did that, Access went on thinking there was a macro associated with it and wouldn't let me do anything else. Everything had to be removed and then start over.

HCEONETMAN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top