I am looking for some help on an access database. I am trying to create a form that will automate a time tracking for a task I need to perform daily. My needs are pretty straight forward.
1. I want a button that when clicked will enter the current date into a text box, but I also want the ability to type a date other than that into the same text box. I want the format to be MM/DD/YYYY.
2. I want a set of buttons (Start Time and End Time) that will do the same thing as above with a timestamp. Also, again the ability to type directly in the text field. I want the format to be HH:MM.
Is this something that is easily accomplished? I have some experience with code behind forms, but would appreciate any help you would offer.
You should be able to just create your buttons and then your text boxes. Basically, the only command functions you need are the now and format functions, I think.
So your code would look something like this for the timestamp:
Code:
Private Sub timestamp_On_Click()
me.txtboxTimeStamp.value =format(Now(), "MM/DD/YYYY")
End sub
...for the start time
Code:
Private Sub starttime_On_Click()
me.txtboxStartTime.value =format(Now(), "HH:MM")
End sub
Use the sub-procedures that rconverse has put in his post and it should accomplish what you want as well. I was just giving you a hotkey option. Do you know how to add that VBA in and have it run?
I believe I do need them for what I am trying to do.
jimr,
I have done some things in code before and believe I am doing it right, but I could be wrong. When I do with the provided code it throws the above error. I made sure I changed the names in the code to reflect my control names, so I don't think it's something I did - but I'm not an expert. Should I post the DB or can someone talk me through it?
Ok, decided I needed to post anyway. I have it working, but on the query I can figure out how to get the appropriate format on the Hours Worked. Can anyone assist? I am not sure how to apply a format in a calculation within a query.
If the Total Time is for one person and for one record it can be calculated on a form.
If the Total Time is for one ot more people and over more than one record then you need a Query.
Which one are you trying to do?
The total time is only for one person, but I want it stored in the DB for reporting purposes. The thought process is to be able to input a date range into the query and have it return the daily totals within that range (weekly totals, monthly totals and such).
If you want to store the data in the table then assuming it has a name like "Hours_Worked" then you would create some VBA in the After Update Event Procedure of the End field on the Form.
me.[Hours_Worked] = me.[End] - me.[Start]
Will Shifts come in to this equation because the Time's hours after midnight are actually less than thos before and will generate an error.
Status
Not open for further replies.
You have insufficient privileges to reply here.
Related Threads
?
?
?
?
?
Tech Support Guy
9.9M posts
859.7K members
Since 1998
A forum community dedicated to tech experts and enthusiasts. Come join the discussion about articles, computer security, Mac, Microsoft, Linux, hardware, networking, gaming, reviews, accessories, and more!