Put the code in a standard module. Make sure it is identified as a Public
Function or Sub.
Call the code from the event. Are you sure you want to use Lost Focus?
Describe what you are doing, please.

Signature
Dave Hargis, Microsoft Access MVP
Thanks Dave,
I have a form which lists cost information for a construction project. Each
value is calculated as a percentage of other values. There is also a manual
override for each field. The manual and calculated are unbound. The script
calculated and checks to see if each cost has a manual entry. If not it
enters the calculated amount into the bound text box. If it does have a
manual it enters that. It has to be on each since changing the value for one
will change it for the others. I also would like to run the script when the
form is opened.
Thanks again, Adam
> Put the code in a standard module. Make sure it is identified as a Public
> Function or Sub.
[quoted text clipped - 16 lines]
> >
> > Adam Kemp
Klatuu - 08 Jan 2008 21:03 GMT
Use the Form's Load event to run it the first time.
Instead of the Lost Focus event, use the After Update event. If you use the
Lost Focus event, you will be running the code when maybe it isn't necessary.
The Lost Focus event fires every time you leave the control. The After
Update event only fires if data in the control has been changed. Using the
Lost Focus event means that you will run the code even if no changes have
been made.

Signature
Dave Hargis, Microsoft Access MVP
> Thanks Dave,
>
[quoted text clipped - 29 lines]
> > >
> > > Adam Kemp
F1stman - 09 Jan 2008 18:50 GMT
Dave,
I feel foolish having to ask this but how do I run the module from the event?
Adam
> Use the Form's Load event to run it the first time.
>
[quoted text clipped - 38 lines]
> > > >
> > > > Adam Kemp
Klatuu - 09 Jan 2008 18:56 GMT
Well, you don't run a module. A module is a contain for Functions and Subs,
so you will be running one of those.
To put code in an event, open the form in design view. Select the control
you want the procedure to run from and open the properties dialog. Select
the Events tab. Select the event you want to use. In this case, the after
update event. Click on the small command button to the right with the 3
dots. When the dialog opens, select Event Procedure. The VB editor will
then open with the cursor positioned in the event sub. Enter the code there.

Signature
Dave Hargis, Microsoft Access MVP
> Dave,
>
[quoted text clipped - 44 lines]
> > > > >
> > > > > Adam Kemp