Use of Me

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have several similar forms that must store/update a stored calclation using
a setvalue function on an onupdate event. The calculation uses a dlookup
variable based on a value found on the form and appears as follows:

[Length]*DLookUp("[FeeX]","tblType Changes","[DeltaC] =" & [Forms]![Data
Entry Form SR-5]![DeltaC])

I would like to apply this formula from a macro triggered by the onupdate
event but the reference to the form value in the dlookup function is
defeating me. I know (but do not really understand) that the term me can be
used to refer to the form having focus. My efforts to use "me" in lieu of
[Forms]![Data Entry Form SR-5]![DeltaC], so that any form having the field
[DeltaC] will work, need some help.

What would the statement look like?

[me]![deltaC] ??
[Forms]![me]![DeltaC] ?? or what?

Thanks for your time.
 
I'd use an event procedure and not a macro.
Usually if you just type ME. the auto-prompter will prompt for the next item.

-Dorian
 
Ken,

Me!DeltaC should be sufficient if it is done in VBA code. If
your DeltaC data is numeric that would make your formula...

[Length]*DLookUp("[FeeX]","tblType Changes","[DeltaC] = " &
Me![DeltaC])

If DeltaC is totally consistent on all uses you could put
this formula in a function wrapper using 'Me' to pass the
form name and save your self redoing the formula every time.
Put the following in a General Module, not a form Module:

Function YourFunctionName(frm as Form) as Currency (???? Is
this returning Currency ????)
YourFunctionName = [Length]*DLookUp("[FeeX]","tblType
Changes","[DeltaC] = " & frm![DeltaC])
End Function

You would now call the function using the Me keyword to fill
in the form parameter (frm)...

YourFunctionName(Me)

Modifying the function to open a recordset to find the value
is actually a bit more efficient than using the Domain
Funtion DLookup() if you really want to do it the best way.
Also beware that there is no error handling in what I gave
you.

--
Gary Miller
Sisters, OR



message
news:[email protected]...
 
Back
Top