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

Field validation

Status
Not open for further replies.

needadvice

Programmer
Apr 7, 2002
145
US
I have a table with a numeric field. The value entered into that field must not be higher than a related field. How do I put a restriction on the table to prevent entering a value higher than the related field.
 
needadvice

You can use the DMax function for the Before Update event...

Winging it...
Code:
Dim lngTest as Long

lngTest = DMax ("[lngSecondField]", "YourTable", "YourWhereClause")

if lngTest <= Me.lngFirstField then
   MsgBox "Must be higher than " & lngTest
   Cancel = True
   Me.lngFirstField.SetFocus
end if

Read up on Dmax for more info...
Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top