DatesAreBad code

>> The above posting suggest putting it on the cmdOK button. <<

I would use the Form_BeforeUpdate() to actually do the validation (or call the validation). And you cmdOK button would just save the data:
Code:
Private Sub cmdOK_Click()
    If Me.Dirty Then Me.Dirty = False
End Sub

When the record is saved the BeforeUpdate event will fire and validate your data.

---

In addition, Papa is definately correct in indicating that you do NOT (99% of the time at least) store the results of calculations in tables.
 
You mean this one? Automating Microsoft Access with VBA

... My friend (Scott Diamond) and I wrote the Access 2007 edition to that book ... Scott was the lead, as I just wrote 4 chapters on ADO and DAO. But, I have to say that I thought the orginal that you referenced (if the link I provided is the correct book) ... well ... was no such a good book. I found many things that were just incorrect or not very well thought out. It has been a while now since I have read it, and I don't mean any disrespect to the authors as they are both intelligent folks ... but ... well ... I will leave it at that, and recommend the following books (in addition to mine of course :) )...

This is one of my favorites ...
Expert Access 2007 Programming

Here is another that may be an option for you (included so as not to seem partial)
Access 2007 VBA Programmer's Reference

And if you want one to help with database design ...
Microsoft Access Small Buisness Solutions: State of the Art Database Models

In addition, and overall book an Access that I often recommend is ...
Access Inside / Out {The link goes to A2010, but they have the Inside/Outs for previous versions as well}

Well, well, well--small world. I have bought so many books, I probably have the others around somewhere. And I am currently using Access 2007 VBA Programmer's Reference--you know some stuff they reference in this book were missing; I left a message on their site and posted on the blog seeking the missing data but no one responded yet.
 
"Why enter data in all the fields when you can add code to do the calculations." I am not understanding how I would do this.

"Is this for each employee to use or for one person to record employee's attendance etc.?" Yes, for everyone eventually.

I am trying to do a simple time-entry form on the computer versus by hand and calculating the total hours.

The hours may vary, sometimes it may be 8 hours or it may be 7 and so on. It may be a five-day week or a three-day week.
 
May not be of any help but here is a link to a litle part of a demo screen that captures start and end times using a scroll bar.
 
"Why enter data in all the fields when you can add code to do the calculations." I am not understanding how I would do this.

I have attached a sample database for you to look at. Open the form frm_timesheet the first record will be displayed so click on Add New Record to a Select a shift from the drop down and the fields will be populated with the shift date(s) and times also the calculations of time worked.

I am trying to do a simple time-entry form on the computer versus by hand and calculating the total hours.

Additional coding will be required to re-calculate the hours when the user changes the start or finish times etc.

The hours may vary, sometimes it may be 8 hours or it may be 7 and so on. It may be a five-day week or a three-day week.
I have included a shift table to enter the shifts start and finish times. This table is the record source for the drop down on the form.

If you require additional help please reply to me off the forum.
 

Attachments

>> Additional coding will be required to re-calculate the hours when the user changes the start or finish times etc. <<

This is precisely the reason way the results of calculations should not be stored in a table. In some circumstances it becomes neccessary, but this is not one of them.

Your table should simply have the start and end time, then you have have a query do the date difference between the start and end. You can use the query object as your forms recordsource if you wish. In addition you can use the query in other places too, like reports and such.
 
I have attached a sample database for you to look at. Open the form frm_timesheet the first record will be displayed so click on Add New Record to a Select a shift from the drop down and the fields will be populated with the shift date(s) and times also the calculations of time worked.



Additional coding will be required to re-calculate the hours when the user changes the start or finish times etc.


I have included a shift table to enter the shifts start and finish times. This table is the record source for the drop down on the form.

If you require additional help please reply to me off the forum.

Okay, your form looks better than mine. I will have to go over it some more--enter some more time and so on.

Thanks!
 

Users who are viewing this thread

Back
Top Bottom