Can you put reasonable limits on fields in Access?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

For example if I know the value to be entered into a field should be between
..010 and .100, can you set the field up to not accept a value that is out of
this range?
 
Yes. A very simple example, without error trapping:

Private Sub urFieldname_BeforeUpdate

If Me.urFieldname < .010 or Me.urFieldname > .100 Then
Msgbox "You can't do that, pal."
Else: Exit Sub
End If

End Sub
 
Quality said:
if I know the value to be entered into a field should be between
.010 and .100, can you set the field up to not accept a value that is out of
this range?

Open the table in design view and click on the column you want to restrict.
Place this in the Validation Rule property:

Between 0.01 And 0.1

Place this in the Validation Text property:

The amount must be between 0.01 and 0.1.
 
You should also set the return value of the Cancel argument to True if the
criteria are not met when validating at control level in the BeforeUpdate
event procedure.

Ken Sheridan
Stafford, England
 

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