access forms

  • Thread starter Thread starter timespan
  • Start date Start date
T

timespan

how can the minimum value from eight numeric fields be found & displayed
displayed on the form, following manual entry?
 
Your only way is through a series of If statements to determine the minimum.
Remember, too, that you may need to handle missing data. You can use the Nz
function in that case, but you need to be able to assign a reasonable value
for comparison purposes if the value is Null.

Dim lngMinimum As Long

lngMinimum = Nz(Me.Field1, 9999)
If Nz(Me.Field2, 9999) < lngMinimum Then
lngMinimum = Me.Field2
End If
If Nz(Me.Field3, 9999) < lngMinimum Then
lngMinimum = Me.Field3
End If
If Nz(Me.Field4, 9999) < lngMinimum Then
lngMinimum = Me.Field4
End If
If Nz(Me.Field5, 9999) < lngMinimum Then
lngMinimum = Me.Field5
End If
If Nz(Me.Field6, 9999) < lngMinimum Then
lngMinimum = Me.Field6
End If
If Nz(Me.Field7, 9999) < lngMinimum Then
lngMinimum = Me.Field7
End If
If Nz(Me.Field8, 9999) < lngMinimum Then
lngMinimum = Me.Field8
End If

(The reason you don't need to use Nz when assigning a value to lngMinimum is
that you know the field's value isn't Null inside each If statement)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top