Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


get the max or mini value to parameter

get the max or mini value to parameter

get the max or mini value to parameter

hi all
how can i get the max value or the mini value from the field and put it to parameter.
i try this code and didn't Benefit.

a = max(field name)
b = mini(field name)
c = a-b
thisform.text1.value = transform(c)

Of course there was an error message!
what the correct code to do that?

RE: get the max or mini value to parameter

Check Calculate in Help.

Calculate Max(FieldName) to lnMax && a, b and c are illegal as memory variable names!
Calculate Min(FieldName) to lnMin

RE: get the max or mini value to parameter

Beware, there also is the MAX() function as you used it, but this will take two parameters and return the higher one (MIN of course the lower one) and is not relted to tables or workareas. Then there is CALCULATE as shown and then you can SELECT MAX(field) from table, also per group in a GROUP BY SQL qurey, which differs from the MAX function in only taking one field (or expression) and returning the max of a group of records (or all records), but only within SQL, as that is part of SQL and not of VFPs own functions.

a-j are addressing workareas, you can use them as variables, but it is not at all recommended. Using variables with VFP name conventions will make the shortest Variable names have 3 letters anyway, and even if you don't want to follow the pattern of a prefix and have straight names, it is not only best practice, but one of least things to do to be able to understand even own code, to be verbose in names. To the compiler any name is just one symbol, so it doesn't make code run slower nor does code using short variable names run faster. Never be lazy, it never pays.

Bye, Olaf.

RE: get the max or mini value to parameter

Thank you very much. Dear Tbleken and Dear Olaf. The experience was successful and I benefited a lot and a lot. I have achieved my goals at the moment using Calculate Max(), and everything is fine and thank Mr.Olaf for the wonderful addition and wonderful useful ...
Greetings to all .

RE: get the max or mini value to parameter

Actually, you can even do all of this in only two lines:

Select max(fieldname), min(fieldname) from yourtable into array laDummy
thisform.text1.value = transform(laDummy(1)-laDummy(2)) 

RE: get the max or mini value to parameter

this idea is very beautiful, wonderful and easy.
Thank you very much Dear tbleken.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close