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

min value in a row

Status
Not open for further replies.

marksch

IS-IT--Management
Feb 14, 2000
1
US
I have a table with 6 fields. sam1,sam2,sam3,sam4,sam5,and minvalue. I am trying to use a setvalue macro to get and automatic entry into the minvalue. all fields are numeric, but the access function seams to work only with numbers in different rows of the same field. How can I get the minimum value out of the five fields in 1 row of data?<br>
<br>
Please help<br>
<A HREF="mailto:Mark@acegrinding.com">Mark@acegrinding.com</A>
 
You can do this by writng a VBA function.<br>
<br>
This should get you started<br>
<br>
Public Function GetMin(Sam1, Sam2, Sam3, Sam4)<br>
Dim db As Database, rst As Recordset, SQL As String<br>
Set db = CurrentDb<br>
' SQL string.<br>
SQL = &quot;SELECT Min(Sam1) AS MinOfField1, Min(Sam2) AS MinOfField2, Min(Sam3) AS MinOfField3, Min(Sam4) AS MinOfField4 FROM Table2;&quot;<br>
Set rst = db.OpenRecordset(SQL)<br>
Debug.Print rst.Fields(&quot;MinOfField1&quot;)<br>
Debug.Print rst.Fields(&quot;MinOfField2&quot;)<br>
Debug.Print rst.Fields(&quot;MinOfField3&quot;)<br>
Debug.Print rst.Fields(&quot;MinOfField4&quot;)<br>
<br>
<br>
End Function<br>
<br>
<br>
<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top