Link to home
Start Free TrialLog in
Avatar of Mohammad Alsolaiman
Mohammad AlsolaimanFlag for Saudi Arabia

asked on

Calculate late hourse?

Hi:
I have two text box controls
AttendTime
LateHours
If I enter any time greater than 6:45 am
It should calculate the lateHours?
For example : if I enter 7:20 am
My LateHours should carry out the value of 35
And what data type I should put to LateHours?
this time i need it on form
Please?
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you want to see just the number 35, change the format of txtLateHours to blank, and set the property Text Align to Right
Avatar of Mohammad Alsolaiman

ASKER

i always get the result of 12:00 am
???
=Format([txtAttendTime]-#06:45:00#,"nn")
i have syntax error
Here's a screen capture of both the form and the property ControlSource.  What can I say?
LateHrs.jpg
You have named both text boxes properly??
notice my access is arabic version
i get this syntax error
it say maybe the coma or cot ... etc
1.JPG
Sorry, I can't help you any further.
Try this:
Create a query for your form's record source (if you don't have one already) and include all the necessary fields from your table.
Then add a calculated field like this:
LateHours: IIf( [AttendTime] > #06:45:00#, DateDiff( "n", #06:45:00#, [AttendTime] ), Null )
Then you can bind this new field (LateHours) to your textbox.
--
Graham
syntax error
1.JPG
sorry
wrong image

1.JPG
I suspect this has something to do with the Arabic version.  It works fine for me.
Are the function names the same in the Arabic version?
Are the rules the same for specifying a literal time?
Can you translate the error message for me?
Have you tried using the Western numbers (06:45:00) instead of the Arabic script?
It's funny - we call the digits we use (0,1,2,3...)  "Arabic" :-)
--
Graham
the message tells that"
The expression you entered has invalid syntax, I omitted a factor or operator, or comma characters or made invalid, or enter text without quotation marks  "
The syntax I gave you should be correct.  Are you able to paste the expression EXACTLY as I gave it to you, or does the Arabic version convert the times to Arabic script?
What does the SQL of the query look like?  Can you please switch from design view to SQL view and post the contents of the SQL window?
I'm assuming that the problem is with the Arabic expression of dates, and hoping that the SQL will be language-independent
Thanks,
--
Graham
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Markus
Your experience with other language versions must far exceed mine (which is zero ;-)) but I was under the impression that SQL is language-independent.  However, the query grid seems to be language-dependent (or at least locale-dependent) because if I enter a date in the query grid as #dd/mm/yyyy# then it gets "translated" to #mm/dd/yyyy# in the SQL window, and vice-versa.
That's why I suggested posting the content of the SQL window.
Good idea to use TimeSerial :-)
Cheers!
--
Graham
PS: I didn't know about the semicolon argument separator.  I guess it makes sense that you can't use a comma if it is being used as a decimal point.  That must affect quite a number of European-based locales.
--
Graham
Graham,

You are absolutely right: the SQL view is language-independent. We can provide the correct SQL syntax, and the author can then show us what it looks like in the query design view. Similar to what you suggested (from a US query grid):

SELECT [...], IIf([AttendTime]>#06:45 AM#, DateDiff('n', #06:45 AM#, [AttendTime]), Null)+0 As LateMinutes, [...]

SQL always uses the comma as list separator, the period as decimal separator, and US or ISO dates between the '#'s.

(°v°)
may be if i upload my mdb file
it will be more clear for you experts
here is one
calculateLateHours.mdb
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it was wonderful discussion
and EE is real business partner i can trust
thank you all very much