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

Numeric field MUST BE 4 CHARs in a form and no less 2

Status
Not open for further replies.

load3d

Programmer
Feb 27, 2008
117
US
I have a field where a user enters a number of equipment hours to track usage on equipment. In order to prevent typographical errors I've added a bunch of checks one of the checks I was hoping to get a quick answer on was


Question:

In the text box field - the user has to enter 4 numbers with a minimum of 0001 and a maximum of 9999. If a user enters 999 i want it to be 0999. I really just need the field to have 4 characthers filled in.



 
In the BeforeUpdate event procedure of the text box:
Code:
If Not (Me![text box] Like "####") Then
  MsgBox "your message here"
  Cancel = True
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Why?
I have a field where a user enters a number of equipment hours to track usage on equipment

Why would you require the user to enter 7 hours as 0007? That is a string which now means doing mathematical checks and calculations is overly complicated.

They should enter 7. Then you can check if the value is numerics and that 0 < 7 < 9999. Then you can format a report, query, or other field to show 0007.
 
I appreciate your analytical approach.

When I was analyzing the data I noticed that they users were simply missing #'s

9041 hours was 941

So, I figure if they are required to type in 4 characthers they would see their mistake. Although, I have nothing yet to stop the user from entering 9141 when the hours are 9041 but I filter those out of the report anyway.


The hours field is the only field that is typed in anyway everything else is using RF ID, thus the hours field is also the only field that has typographical errors.

 
How were you able to determine they really meant 9041 vice 941? If there is a rule that allows you to determine 941 was a mistake then implement that error checking in the before update event. For example if 90% of your records should have operating hours over 1000 then have the user verify any entry less than 1000. Or if there are some other field values that would signal 941 is not legit, then check those.
 
Without going to far into it because it's hard to explain and but I have two sets of hours, check in hours and check out hours

if check in hours reads 941 and check out hours reads 9045 it's more likely that the machine only ran for 4 hours rather rolled over to 000 and put on another 941 hours before being checked back in. Other records would indicate that 941 is not correct. Anyway, that was just one example and I'm just trying to reduce that. For reporting I'm filtering out any number of hours that exceeds 10 hours or is less than 1 hour.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top