Calculate Elapsed Time: Same Expression Works and Fails Somewhere

R

Robert T

Hello:

I’m relatively new to Access so I’m still confused by some of the things
that happen. I have a basic form that calculates elapsed time for my daily
work schedule. Here’s the expression I copied from the Control Source:

=HoursAndMinutes([EndTime] -[StartTime])

It works perfectly. However, I tried showing one of my co-workers how to
create a calculated field on a form to do the same thing, using the above
expression, and much to my amazement, I received the following error message:

#name?

I checked the spelling, the name of the control, and did everything I could
think of, but that expression still results in #name?

I went online and found another way to calculate elapsed time on a form and
this one works. I don’t understand why the following expression works but the
one above doesn’t. This one calculates elapsed time in minutes so I have
another calculated field on the form that converts it to hours and minutes.
Can someone please explain that to me.

=DateDiff("n",[StartTime],[EndTime])

=[TotalTimeWorked]\60 & Format([TotalTimeWorked] Mod 60,"\:00")

Thanks,
Robert
 
D

Daveo

Hello:

I'm relatively new to Access so I'm still confused by some of the things
that happen. I have a basic form that calculates elapsed time for my daily
work schedule. Here's the expression I copied from the Control Source:

=HoursAndMinutes([EndTime] -[StartTime])

It works perfectly. However, I tried showing one of my co-workers how to
create a calculated field on a form to do the same thing, using the above
expression, and much to my amazement, I received the following error message:

#name?

I checked the spelling, the name of the control, and did everything I could
think of, but that expression still results in #name?

I went online and found another way to calculate elapsed time on a form and
this one works. I don't understand why the following expression works but the
one above doesn't. This one calculates elapsed time in minutes so I have
another calculated field on the form that converts it to hours and minutes.
Can someone please explain that to me.

=DateDiff("n",[StartTime],[EndTime])

=[TotalTimeWorked]\60 & Format([TotalTimeWorked] Mod 60,"\:00")

Thanks,
Robert

Hi Robert,

Is HoursandMinutes(x) some sort of custom function/formatting to
convert the number you get from [EndTime]-[StartTime] into hours and
minutes? I don't seem to have it available in my expression builder.
Maybe your co-worker doesn't have it either?

Cheers - David
 
D

Dale Fye

Robert,

Check in your VB Editor window and see if you can find the function
HoursAndMinutes( ). Place your cursor in any code window, then click Edit -
Find from the VB tool bar. Type "HoursAndMinutes" in the "find what" text
box of the dialog box, and click the Current Project radio button. Then
click find next.

Once you know what code module it is in, you can import that module into
your coworkers database from your database using the File - Get External Data
- Import menu options (assuming that your database is accessable to him
across your network).
 
R

Robert T

Thanks guys for the excellent suggestions. I have to teach classes most of
the morning but I'll try out that suggestion after my classes.

Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top