Function - Module

  • Thread starter Thread starter learning_codes
  • Start date Start date
L

learning_codes

Hi,

I need your help if it makes sense. I tried to test it and I didn't
get any result because of missing information. I'm not sure if I miss
something.

Public Function Result (year_A,year_B,factor_C,year_B,tenure_D)
Result = min(year_A,max(year_B,factor_C),max(year_B,tenure_D));
End Function

Thanks for your help....
 
well, first of all, you've given the same name to two different arguments in
your custom function - year_B. in practical terms, you can't do that because
the system will have no idea which argument to use when it's referenced in
the procedure. in fact, i'm surprised that the code didn't err when you
compiled the module - or have you not compiled your code?

second, Access Help says that the Min() and Max() functions "return the
minimum or maximum of a set of values contained in a specified field *on a
query*." it doesn't say that you can use those functions in VBA code, and in
fact when i wrote them in a module window in my db (Access2000 running in
Access2003), they weren't recognized by the system. and beyond that, a
custom function argument will contain only one value - unless it's been
defined as a collection (or possibly as an array, though i don't know if an
array can be passed to a procedure in that manner) - so what would be the
point of trying to return the minimum or maximum of *one value*?

can you explain what you're trying to do?

hth
 
Back
Top