instead of all the ANDs, you can put: Second([DTG])=0 And Minute([DTG]) In (0,15,30,45) For these situations, I like to use a combo box (or List box depending on data) with the Possible times pre-populated. I then set the properties of the Combo box to "Limit To List" Yes and "Allow Value List Edits" No. This makes it impossible for the User to enter invalid entries, which negates the need for validation checks (as an alternative).
@599CD3 жыл бұрын
Excellent suggestions! Thanks.
@resrussia3 жыл бұрын
I tried a different approach to the issue using the following validation rule: Minute([DateTime]) Mod 15 =0. I tested this out and it seems to work and it seems like it would be more efficient way to code the validation. It appears that that checking for the seconds is not necessary unless the user's requirement specified seconds be entered as part of recording of the time and the number of seconds is significant for user's application. Three possible scenario based upon your student's question: Scenario 1: User is not required to enter seconds and the number of seconds is not significant for the application. If the user enters 1:15, then there is no reason to check the number of seconds, because Access will assume that 1:15 is 1:15:00, exactly a 15 minute interval. Scenario 2: User is required to enter seconds and the number of seconds is not significant for the application. If the user enters 1:15:34 then there is no reason to check the number of seconds, because the minute part of the time is important for application is only in the minute portion of the time. Scenario 3: User is required enter seconds and the number of seconds is significant for the application. If the user enters 1:15:34 then it will be necessary to check for seconds because application needs the have precisely 1:15:00. In this scenario, the validation function could look something like: Second([Date]) And Minute([DateTime]) Mod 15 =0 In the worst case scenario, a time with 45 in it, would take more time to evaluate because Access would need to check each of the other possibilities for minute (I assume that when one the minute comparisons is true, Access stops the evaluation process). Of course this analysis depends on the relevant amount it takes Access to execute Mod function vs comparing the results of each of Minute function. Your guidance on why your solution is better than my solution would greatly be appreciated.
@resrussia3 жыл бұрын
One additional point to using the Mod function is that if business rule for the interval changes, the update is extremely simple. For example, suppose the business rule changes from 15 minute intervals to 10 minute intervals. Using the Minute([DateTimefield]) Mod 15 = 0 method, the change is merely changing the 15 to 10.The new statement would be Minute([DateTimefield] Mod 10 = 0 . Using the method in the video,all four the Or statements would need updating and two new Or statement would need to be added. So, Minute([DateTimefield]) = 00 Or Minute([DateTimefield]) = 15 Or Minute([DateTimefield]) = 30 or Minute([DateTimefield])=45 or Minute([DateTimefield]) =40 would become Minute([DateTimefield]) = 00 Or Minute([DateTimefield]) = 10 Or Minute([DateTimefield]) = 20 or Minute([DateTimefield])=30 or Minute([DateTimefield]) =40 or Minute([DateTimefield])=50 with last two statements needing to added.
@599CD3 жыл бұрын
Thank you for the suggestions. As with everything in Access there are always multiple ways to get the job done. :)