Date Range in Table

  • Thread starter ladybug via AccessMonster.com
  • Start date
L

ladybug via AccessMonster.com

I want to create a form where a user can enter in data for a date range.

Example:
An employee works 5 hours on Monday 5/1, 5 hours on Tuesday 5/2, and 3 hours
on Thursday.

I want the user to be able to input on the form that the employee worked 13
hours for the week instead of inputing each day. Does anyone have any
creative ideas in how this could work? I am open to any suggestions. Thank
you.
 
R

Rob Parker

How about sending your users back to primary school, so they can learn to
add up in their heads ;-)

Or, teach them to use the Windows Calculator program, if mental arithmetic
is too hard !!!

Failing that, you could use an unbound text-box for input, and use its
AfterUpdate event to set a bound textbox (which could be hidden) which will
enter the data into your table, using code such as:
txtHoursWorked = Eval(txtInput)
This would let your users enter data as s string such as "5+5+3". However,
if they enter a string which cannot be evaluated, you will get an error, so
you'll need some substantial error-trapping for this to work reliably. Some
explanatory text on the form could perhaps be useful, but I wouldn't rely
solely on that. Not worth the trouble, in my opinion, but it's your
application ...

HTH,

Rob
 
L

ladybug via AccessMonster.com

Sorry, I don't think that I explained correctly.
I want to know how many hours each employee worked for each week. I don't
want to put in each day.

What about a format where the user could only enter dates that are a Sunday.
That way a user could not enter in a Monday, Tuesday, etc. Then I can just
make the label Week of:

It would then symbolize for the whole week.

Rob said:
How about sending your users back to primary school, so they can learn to
add up in their heads ;-)

Or, teach them to use the Windows Calculator program, if mental arithmetic
is too hard !!!

Failing that, you could use an unbound text-box for input, and use its
AfterUpdate event to set a bound textbox (which could be hidden) which will
enter the data into your table, using code such as:
txtHoursWorked = Eval(txtInput)
This would let your users enter data as s string such as "5+5+3". However,
if they enter a string which cannot be evaluated, you will get an error, so
you'll need some substantial error-trapping for this to work reliably. Some
explanatory text on the form could perhaps be useful, but I wouldn't rely
solely on that. Not worth the trouble, in my opinion, but it's your
application ...

HTH,

Rob
I want to create a form where a user can enter in data for a date range.
[quoted text clipped - 9 lines]
Thank
you.
 
J

John Vinson

I want to know how many hours each employee worked for each week. I don't
want to put in each day.

What about a format where the user could only enter dates that are a Sunday.
That way a user could not enter in a Monday, Tuesday, etc. Then I can just
make the label Week of:

You could have a Date/Time field in your table, named WeekOf; you can
use a Form to do the data entry, and have this field default to the
most recent previous Sunday by setting the DefaultValue property of
its textbox to

=DateAdd("d", 1 - Weekday(Date()), Date())

Use -6 - Weekday(Date()) if you want the previous week's Sunday.

John W. Vinson[MVP]
 
R

Rob Parker

Sorry from my end - I was answering what you asked, not what you wanted ;-)

Prompted somewhat by John Vinson's reply, you could use a textbox (let's
call it txtWeekDate), with a Validation Rule of:
Weekday([txtWeekDate]) = 1
and a Validation Text entry of (for example)
"That date is not a Sunday!"

This would only allow users to enter a date for a Sunday into your textbox;
it would display the text in a message box for any other date.

Again, HTH,

Rob

ladybug via AccessMonster.com said:
Sorry, I don't think that I explained correctly.
I want to know how many hours each employee worked for each week. I don't
want to put in each day.

What about a format where the user could only enter dates that are a
Sunday.
That way a user could not enter in a Monday, Tuesday, etc. Then I can
just
make the label Week of:

It would then symbolize for the whole week.

Rob said:
How about sending your users back to primary school, so they can learn to
add up in their heads ;-)

Or, teach them to use the Windows Calculator program, if mental arithmetic
is too hard !!!

Failing that, you could use an unbound text-box for input, and use its
AfterUpdate event to set a bound textbox (which could be hidden) which
will
enter the data into your table, using code such as:
txtHoursWorked = Eval(txtInput)
This would let your users enter data as s string such as "5+5+3".
However,
if they enter a string which cannot be evaluated, you will get an error,
so
you'll need some substantial error-trapping for this to work reliably.
Some
explanatory text on the form could perhaps be useful, but I wouldn't rely
solely on that. Not worth the trouble, in my opinion, but it's your
application ...

HTH,

Rob
I want to create a form where a user can enter in data for a date range.
[quoted text clipped - 9 lines]
Thank
you.
 
L

ladybug via AccessMonster.com

Thank you Rob, that worked great.
I went ahead with your solution because they may need to go in and track data
from a month ago.

Sorry again if I was confusing, I don't really know the technical terms to
Access! :)

Rob said:
Sorry from my end - I was answering what you asked, not what you wanted ;-)

Prompted somewhat by John Vinson's reply, you could use a textbox (let's
call it txtWeekDate), with a Validation Rule of:
Weekday([txtWeekDate]) = 1
and a Validation Text entry of (for example)
"That date is not a Sunday!"

This would only allow users to enter a date for a Sunday into your textbox;
it would display the text in a message box for any other date.

Again, HTH,

Rob
Sorry, I don't think that I explained correctly.
I want to know how many hours each employee worked for each week. I don't
[quoted text clipped - 38 lines]
 

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