Data entry operators continually enter data for consecutive ranges and I
want to set default values to fields from the previous record. Every now and
again they will change the default values as well.
For example:
From To Value
0 1 X
1 2 Y
2 3 Z etc...
So, when creating the next record I want the default for 'From' to be the
previous value from the 'To' field.
If I can get that default set then I can also increment the 'To' value (e.g.
previous record + 1) so that the operator only needs to enter the 'Value'
field during data entry.
Every keystroke saved is a possible error avoided!
I've had a bit of a play around using the OnCurrent event and moving in the
recordset but it has not been robust enough for my liking.
--
"If you bite off more than you can chew; chew like hell..." (Peter Brock)
Me.ControlName.DefaultValue = """" & Me.ControlName & """"
That's 4 double quotes on each side.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
"Barry" <Ba...@discussions.microsoft.com> wrote in message
news:698FD55C-9EC3-4401...@microsoft.com...
>Access 2003...
>Creating a data entry form using a datagrid subform.
>
>Data entry operators continually enter data for consecutive ranges and I
>want to set default values to fields from the previous record. Every now and
>again they will change the default values as well.
>
>For example:
>From To Value
>0 1 X
>1 2 Y
>2 3 Z etc...
>
>So, when creating the next record I want the default for 'From' to be the
>previous value from the 'To' field.
>If I can get that default set then I can also increment the 'To' value (e.g.
>previous record + 1) so that the operator only needs to enter the 'Value'
>field during data entry.
>
>Every keystroke saved is a possible error avoided!
This depends on how you define "previous". If it is the
record that appears above the new record, then "previous" is
totally dependent on how the loaded records are filtered and
sorted.
OTOH, if "previous" means the most recently created record,
then it depends on whether you are talking about the current
session or any session. If the latter, then you must have a
field in the table that can be used to identify the last
record to be created and use some code in the form's Load
event to lookup the value and set the DefaultValue
properties.
The current session case is the only one that is relatively
easy to deal with. Here, I think you can use the form's
AfterInsert event to set the DefaultValue property with code
like:
Me.txtFrom.DefaultValue = Me.txtTo
Me.txtTo.DefaultValue = Me.txtTo + 1
--
Marsh
MVP [MS Access]
The datasheet was also requeried by a combo box on parent form so it only
showed one date of data entry.
So, select different date, do data entry for that date - usual thing.
I've also followed up with an event in the combo OnChange to also change the
defaults to the last record for that selected date of data so that the
previously entered values do not end up as defaults for the new record in a
different set of data. It makes complete sense if you see it in operation of
course... :)
Cheers
Lynton
--
"If you bite off more than you can chew; chew like hell..." (Peter Brock,
r.i.p.)