Inputing a reusable value on a form (batching)

G

Guest

I have a form that I use to ADD new time sheets for a given time period. One
field I use is a "Period Ending Date"[PEDATE]. This date is the same for
all of the time sheets and I would like to only input it ONCE when the form
opens and have it automatically fill end that date in the [PEDATE] field for
all of the time sheets that I add for that session. I would also like to
skip that field when I'm inputing the rest of the data.
 
A

Allen Browne

To use the last entered date as the default for new records, set the text
box's Default Value in its After Update event procedure.

DefaultValue is a string value, so the code would be something like this:
Private Sub PEDATE_AfterUpdate()
With Me.PEDATE
If Not IsNull(.Value) Then
.DefaultValue = "=""" & .Value & """"
.TabStop = False
End If
End With
End Sub

Setting its TabStop property to No means it is skipped once the value has
been set.

If the PEDate is the same for all records, would it be a better design to
create a little table to hold the BatchNum and PeriodEndDate, and have a
BatchNum instead of a PEDate? It seems to me that this would be more
reliable and more flexible (e.g. to undo a batch.)
 
G

Guest

Thanks Allen. It worked.
I'm an old dbase user and I find access concepts much more difficult to
grasp.

I just didn't want to have to manually enter the date more than once a
session.
(The time sheets come in over a two weeks period and different people may
enter the info and sometimes enter the wrong period ending date and I end up
with bad stored info.)
I have another question.
The pay period is always on the 10th and the 25th of the month. Is there
some way I can be sure the user only enters one or the other "day"? Also, is
there a way to "warn" the user that the date on a job sheet [jobdate] is from
another pay period but still let them enter it? (Sometimes it's a typing
error but sometimes the guys turn them in late.)

--
Ameteur Access 2000 User
Thanks Bobbye


Allen Browne said:
To use the last entered date as the default for new records, set the text
box's Default Value in its After Update event procedure.

DefaultValue is a string value, so the code would be something like this:
Private Sub PEDATE_AfterUpdate()
With Me.PEDATE
If Not IsNull(.Value) Then
.DefaultValue = "=""" & .Value & """"
.TabStop = False
End If
End With
End Sub

Setting its TabStop property to No means it is skipped once the value has
been set.

If the PEDate is the same for all records, would it be a better design to
create a little table to hold the BatchNum and PeriodEndDate, and have a
BatchNum instead of a PEDate? It seems to me that this would be more
reliable and more flexible (e.g. to undo a batch.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Bobbye said:
I have a form that I use to ADD new time sheets for a given time period.
One
field I use is a "Period Ending Date"[PEDATE]. This date is the same for
all of the time sheets and I would like to only input it ONCE when the
form
opens and have it automatically fill end that date in the [PEDATE] field
for
all of the time sheets that I add for that session. I would also like to
skip that field when I'm inputing the rest of the data.
 
A

Allen Browne

You can test the Day() of the date, e.g.:
If (Day(Me.PEDATE) <> 10) AND (Day(Me.PEDATE) <> 25) Then ...

Likewise, you can test whether the date is before the beginning of the
current pay period, e.g.:
If Me.PEDate < DateSerial(Year(Date), Month(Date), 10) Then


--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.
Bobbye said:
Thanks Allen. It worked.
I'm an old dbase user and I find access concepts much more difficult to
grasp.

I just didn't want to have to manually enter the date more than once a
session.
(The time sheets come in over a two weeks period and different people may
enter the info and sometimes enter the wrong period ending date and I end
up
with bad stored info.)
I have another question.
The pay period is always on the 10th and the 25th of the month. Is there
some way I can be sure the user only enters one or the other "day"? Also,
is
there a way to "warn" the user that the date on a job sheet [jobdate] is
from
another pay period but still let them enter it? (Sometimes it's a typing
error but sometimes the guys turn them in late.)

--
Ameteur Access 2000 User
Thanks Bobbye


Allen Browne said:
To use the last entered date as the default for new records, set the text
box's Default Value in its After Update event procedure.

DefaultValue is a string value, so the code would be something like this:
Private Sub PEDATE_AfterUpdate()
With Me.PEDATE
If Not IsNull(.Value) Then
.DefaultValue = "=""" & .Value & """"
.TabStop = False
End If
End With
End Sub

Setting its TabStop property to No means it is skipped once the value has
been set.

If the PEDate is the same for all records, would it be a better design to
create a little table to hold the BatchNum and PeriodEndDate, and have a
BatchNum instead of a PEDate? It seems to me that this would be more
reliable and more flexible (e.g. to undo a batch.)

Bobbye said:
I have a form that I use to ADD new time sheets for a given time period.
One
field I use is a "Period Ending Date"[PEDATE]. This date is the same
for
all of the time sheets and I would like to only input it ONCE when the
form
opens and have it automatically fill end that date in the [PEDATE]
field
for
all of the time sheets that I add for that session. I would also like
to
skip that field when I'm inputing the rest of the data.
 
G

Guest

Allen, thanks again. I noticed you have a tips website. I'm sure I'll find
it helpful in the future.
--
Ameteur Access 2000 User
Thanks Bobbye


Allen Browne said:
You can test the Day() of the date, e.g.:
If (Day(Me.PEDATE) <> 10) AND (Day(Me.PEDATE) <> 25) Then ...

Likewise, you can test whether the date is before the beginning of the
current pay period, e.g.:
If Me.PEDate < DateSerial(Year(Date), Month(Date), 10) Then


--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.
Bobbye said:
Thanks Allen. It worked.
I'm an old dbase user and I find access concepts much more difficult to
grasp.

I just didn't want to have to manually enter the date more than once a
session.
(The time sheets come in over a two weeks period and different people may
enter the info and sometimes enter the wrong period ending date and I end
up
with bad stored info.)
I have another question.
The pay period is always on the 10th and the 25th of the month. Is there
some way I can be sure the user only enters one or the other "day"? Also,
is
there a way to "warn" the user that the date on a job sheet [jobdate] is
from
another pay period but still let them enter it? (Sometimes it's a typing
error but sometimes the guys turn them in late.)

--
Ameteur Access 2000 User
Thanks Bobbye


Allen Browne said:
To use the last entered date as the default for new records, set the text
box's Default Value in its After Update event procedure.

DefaultValue is a string value, so the code would be something like this:
Private Sub PEDATE_AfterUpdate()
With Me.PEDATE
If Not IsNull(.Value) Then
.DefaultValue = "=""" & .Value & """"
.TabStop = False
End If
End With
End Sub

Setting its TabStop property to No means it is skipped once the value has
been set.

If the PEDate is the same for all records, would it be a better design to
create a little table to hold the BatchNum and PeriodEndDate, and have a
BatchNum instead of a PEDate? It seems to me that this would be more
reliable and more flexible (e.g. to undo a batch.)

I have a form that I use to ADD new time sheets for a given time period.
One
field I use is a "Period Ending Date"[PEDATE]. This date is the same
for
all of the time sheets and I would like to only input it ONCE when the
form
opens and have it automatically fill end that date in the [PEDATE]
field
for
all of the time sheets that I add for that session. I would also like
to
skip that field when I'm inputing the rest of the data.
 

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