How to not allow Time entry to change once entered.

omarrr128

Member
Local time
Today, 13:20
Joined
Feb 5, 2023
Messages
72
time.png

I have this job booking system where the start time and end time is recorded. Only problem is that if the user takes their name off and puts it back on then the timer resets to the current time. Is it possible to allow only one time entry and then to lock after that and not change at all?

I want the user to be allowed to take their name off if they want but for the Start time to not change at all once started.

Thank you
 
If you allow the user to access a table, you have little or no control over the contents of a record. In that case, the answer is "you can't."

If you use a form, however, you can program the form to refuse to allow a change once there is a non-default value in a given control.

When taking this approach, you will need to do some event-level programming. For example, for a new record you would have some predictable zeros and/or blanks to let you know it IS a new record. In the form's Current event, you would test the fields to verify that they are all set at the default value, whatever it might be. I might use a LostFocus event on the controls, though others might suggest a different event would be better. In either case, you would lock the control, which would prevent further changes.

A question that needs to be considered is whether you will allow a user to make a correct before committing the start and stop times. There also is usually a way to correct an erroneous entry even after it was saved if you are a suitably enabled user.

Think about what you want to do. Odds are it can be done within the context of a simple data entry form.
 
the List Form should only be Read-Only.
on design view of form form_joblist2, set these two properties to No:
not_allowed.png


next, add code to BeforeInsert:
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
Cancel = True
End Sub
 
You need code in two events.

In the form's current event
Code:
If Me.NewRecord = True Then
    Me.StartTime.Locked = False
Else
    Me.StartTime.Locked = True
End if
Then in the form's AfterUpdate event but only if you want to prevent changing the time after saving the record but before leaving it.
Code:
    Me.StartTime.Locked = True
 
the List Form should only be Read-Only.
on design view of form form_joblist2, set these two properties to No:
View attachment 106316

next, add code to BeforeInsert:
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
Cancel = True
End Sub
unfortunately this hasnt worked. I want the users to be able to add their names to a job and also add notes to it if necessary. I just need the start time to never change once it has been set.

im thinking some sort of code like : after jobstart update, lock it from changing. im not sure how to put that in code though.
 
Last edited:
ok, try and test this one.
see the code of Current event and the Click event of the porter combobox.
 

Attachments

ok, try and test this one.
see the code of Current event and the Click event of the porter combobox.
YES. Thank you a lot once again. Youre very smart. Thats the last thing I needed to do on this project. Thank you very much for your help :)))
 
I gave you the solution early yesterday afternoon. I guess you didn't read it.
 
ok, try and test this one.
see the code of Current event and the Click event of the porter combobox.
This code has 1 issue im afraid. It doesnt work when a new record is created through "new job" form. You can assign a porter to the job but It will not allow any Start Time to be added at all. Is there any way to fix that? I have tried messing around with the code but nothing works, I will upload an updated version.

Thank you :)
 

Attachments

I tried them but they didnt seem to work. Sorry
Your problem is partially with the timer event. The other problem is the problem statement. Start time is NOT entered on the jobs list form. It is entered by default when the record is created and since that happens on a different form so the suggested changes were all wrong.

You never defined whether the start time could be changed. If it can't be changed, then the field should be permanently locked. If it can be changed, then you need to define under what conditions it can be changed. If the intention is to calculate the elapsed time from when the request is logged until the task is completed, then the start time should never change.

Also, how are you recording the finish of the task? Are there kiosks at every location so as soon as the porter arrives he can click finish? Does each porter have a phone he is using to log the completion? This form would be a nightmare on a phone so that can't be it. It would be awful even on a tablet. If there is some time between recording the finish and the actual finish, you will have to rely on the honesty of the porters.

Just an idea that might help with recording the finish.
1. Create barcodes that the porter can scan at the entrance to each location.
2. Give the porters id's with their personal barcode.

Then the app can reconcile the porter/to location to find the record to mark finished.

This form is poorly implemented
--The tab order is random so you can't tab from control to control
--You have no visual clue what control the focus is in
--There is no validation so records can be saved with missing/invalid data
--Too much scrolling with data entry fields to the right instead of to the left. By the time the user focuses on what he wants to change, the timer event runs and requeries the form making him lose his place.
--This form allows new records to be added and it should NOT since they need to be created in the new job form.

Subbestion:
--Separate the start and end actions into two different forms The first field on the "end" form should be the porter since the porter has only one job at a time. That will be the easiest thing to search for. AND the list should be sorted by porter rather than time or patient. The start action is more difficult. I would add a groupID to group locations to help the porter find the next job nearest to his current location. OR, maybe you could be smart and when he records an end time, offer him the closest jobs to his current location.
 
Last edited:
I tried them but they didnt seem to work. Sorry
When something offered does not work, you need to come back and say *exactly* what did not work, error message, line of code where it failed etc.?

People here are very good, but they are not mindreaders. :(
 
Your problem is partially with the timer event. The other problem is the problem statement. Start time is NOT entered on the jobs list form. It is entered by default when the record is created and since that happens on a different form so the suggested changes were all wrong.

You never defined whether the start time could be changed. If it can't be changed, then the field should be permanently locked. If it can be changed, then you need to define under what conditions it can be changed. If the intention is to calculate the elapsed time from when the request is logged until the task is completed, then the start time should never change.

Also, how are you recording the finish of the task? Are there kiosks at every location so as soon as the porter arrives he can click finish? Does each porter have a phone he is using to log the completion? This form would be a nightmare on a phone so that can't be it. It would be awful even on a tablet. If there is some time between recording the finish and the actual finish, you will have to rely on the honesty of the porters.

Just an idea that might help with recording the finish.
1. Create barcodes that the porter can scan at the entrance to each location.
2. Give the porters id's with their personal barcode.

Then the app can reconcile the porter/to location to find the record to mark finished.

This form is poorly implemented
--The tab order is random so you can't tab from control to control
--You have no visual clue what control the focus is in
--There is no validation so records can be saved with missing/invalid data
--Too much scrolling with data entry fields to the right instead of to the left. By the time the user focuses on what he wants to change, the timer event runs and requeries the form making him lose his place.
--This form allows new records to be added and it should NOT since they need to be created in the new job form.

Subbestion:
--Separate the start and end actions into two different forms The first field on the "end" form should be the porter since the porter has only one job at a time. That will be the easiest thing to search for. AND the list should be sorted by porter rather than time or patient. The start action is more difficult. I would add a groupID to group locations to help the porter find the next job nearest to his current location. OR, maybe you could be smart and when he records an end time, offer him the closest jobs to his current location.
Thank you for your advice but i think you are overcomplicating things. The system was made by someone else and I am trying to improve it. I cannot change too much as people will not know how to use the new system then. Barcodes are therefore not an option. Porters currently come back to the main computer to click job complete.

Anyways my problem is just with the start timer.

Thank you for your time though.
 
try and test this.

unfortunately this doesnt work either and has made it worse.


In this video I have tried to show my problem.

The empty record template that's already on the screen works perfectly. You can see I add a name, the start time instantly begins and cannot be changed even if a name is added or removed.

When I create a new job however and add a name to it, no start time appears at all. If you are able to fix that and make it work like above I would be very grateful. Thank you.
 
You are using two different forms to create the record and that is causing the confusion. It makes no sense to allow the "wide" form to create a record since it doesn't allow you to specify what the task is. Set the AllowAdditions property to No for that form and ONLY add on the other form.

It also makes no sense to make the porters come back to "home base" and then get sent back to where they came from. Software should NOT make a task less efficient and that is what this software does.
 
try it again.
Thank you once again for ur time but unfortunately this hasnt worked either.

ive tried to explain in my video verbally this time what my request is. If you cant do it thats completely fine. You have done more than enough which I am very thankful for :)

If you are still confused about what i want please let me know.

 

Attachments

did you download the db i uploaded on post#17.
if you did, then i cannot re-create your problem.
the video is using the db i posted on post#17.
 
i have tried that version but it works less effectively than the one i attached in #18.

When you create a new job it allows maybe 15 seconds for the time to be changed. Not sure why. Thats why it worked in the video as you were quick to add a name.

Create a job and wait a minute or so and then try to add a Porter name to it. You will see the time does not change and will remain the same time as when the job was created.
 

Users who are viewing this thread

Back
Top Bottom