max number

A

atros

i have a form in access 2003 with 5 textbox
who can i fount the max number of this 5 textbox
to another textbox, ever time who i change the values
in the 5 textboxs
 
J

John Nurick

One way is to put a function like this (air code) in the form's module.
It assumes the textboxes are named txt1, txt2 and so on.

Function GetMaxNumberFromTextboxes As Double
Dim MaxSoFar As Double
Dim X as Double

'Get value from first textbox
'allowing for the possibility of non-numeric
'or Null values
MaxSoFar = Val(Nz(Me.txt1.Value))

D = Val(Nz(Me.txt2.Value))
If D > MaxSoFar Then MaxSoFar = D

D = Val(Nz(Me.txt3.Value))
If D > MaxSoFar Then MaxSoFar = D

D = Val(Nz(Me.txt4.Value))
If D > MaxSoFar Then MaxSoFar = D

D = Val(Nz(Me.txt5.Value))
If D > MaxSoFar Then MaxSoFar = D

GetMaxNumberFromTextboxes = MaxSoFar

End Function

Then call the function from each textbox's AfterUpdate event procedure,
to update the other textbox, e.g.

Me.txtOther.Value = GetMaxNumberFromTextboxes()
 

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

Top