Invoice hour checking by date

wizcow

Registered User.
Local time
Today, 14:57
Joined
Sep 22, 2001
Messages
236
Hi

As I enter tickets into my invoice, I enter the ticket date and the straight time hours.
I would like to have access check to make sure I do not enter more than 8 hours on any one day.


I think it should be something like this....

If straighttimehours < 8 (for this date) then
msgbox "You have more that 8 hours entered"
end if

I'm having trouble writing the date part of this code.

Help!
Tom
 
You can use the Date() function. Always returns todays date, in short date format.

Dim dDate As Date

dDate = Date

Thus... dDate = 8/24/2004.

So...

If txtTicket Date = Date And StraightTimeHours <= 8 Then
MsgBox "Good work Hombré"
Else
msgbox "You have more than 8 hours entered"
end if

fior the record, Time always returns the current time, based on your computer, in HH:MM:SS Format (I Think)

Now returns both current time & Date.

In control source of textbox, you can enter
=Date() or =Now() or =Time()

in VBA it's just Date or Time etc... no brackets, equal signs where necessary.

Good Luck
 
DB7

Thanks for the reply!

That almost did it, but...
I want to be able to enter all my tickets one day at the end of the week.
So ticket dates will not be todays date.

If I enter five tickets for Aug 11/04 (for instance), each worth 2 hours,
I would like to check to make sure the last ticket is entered as Overtime.

Any ideas?

Tom
 
Tom,

After they/you enter a charge, do this:

DSum("[HoursWorked]", "YourTable", "[ChargeDate] = #" & Me.FormDate & "#")

Wayne
 
You guys are the best!

Thanks DB7 and Wayne.
I used this and it works great.

Code:
If DSum("[StraightTime]", "tblInvoiceSub", "[Date] =  Forms![frmInvoice]![frmInvoiceSub].form![date] ") > 8 Then
MsgBox "You Have Exceded 8 Hours Of Straight Time."
End If

Tom
 

Users who are viewing this thread

Back
Top Bottom