writing an expression in the default value property

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm working on an employee/event database, where I can track which employees
worked which events, and how many hours, etc. I've set up the employees with
a current pay rate, and I have a field in a subform for their pay rate as it
relates to a particular event. I'm trying to set it up so that the default
in that pay rate field comes up as the employees current pay rate, but I seem
to be striking out. I've been trying to write an expression for the default
value property of the payrate field that points to the employees current pay
rate, but can't seem to figure it out.

Any help? Please?

Thanks!
 
Krissie,

It depends where you are trying to do this. If, as I imagine, the
subform is a subform of employees on a particular event, you won't be
able to do this as a Default Value. The Default Value is assigned at
the point where a new record is started, and at that point in your data
entry, Access can't know which employee, so it can't know which pay
rate. You could, however, use a VBA procedure on the After Update event
of the control (combobox?) where you enter the employee. If, on the
other hand, the subform is on the Employee form, you could use a DLookup
function in the Default Value of the subform's pay rate control. Or,
more simply, you could refer to the current pay rate control on the main
form, something like [Parent]![CurrentPayRate].

If you need more explicit help, maybe you could post back with more
information about the form and subform.
 
Thanks! I have it set up kind of like you mentioned first. I have an
Employee table and form, then I have an Event Table, and a Junction Table,
since they'll have a many-to-many relationship. In the juction table is the
pay rate field since it's unique to the employee-event combination, and I
have an Event Form with a Junction Subform. On my Junction Subform, I have a
combobox pulling up the Employee from the Employee table, and in the second
column it lists their current pay rate. I was just starting to get the after
update event part of it, but still can't get the expression right.

Can you help?

Steve Schapel said:
Krissie,

It depends where you are trying to do this. If, as I imagine, the
subform is a subform of employees on a particular event, you won't be
able to do this as a Default Value. The Default Value is assigned at
the point where a new record is started, and at that point in your data
entry, Access can't know which employee, so it can't know which pay
rate. You could, however, use a VBA procedure on the After Update event
of the control (combobox?) where you enter the employee. If, on the
other hand, the subform is on the Employee form, you could use a DLookup
function in the Default Value of the subform's pay rate control. Or,
more simply, you could refer to the current pay rate control on the main
form, something like [Parent]![CurrentPayRate].

If you need more explicit help, maybe you could post back with more
information about the form and subform.

--
Steve Schapel, Microsoft Access MVP

I'm working on an employee/event database, where I can track which employees
worked which events, and how many hours, etc. I've set up the employees with
a current pay rate, and I have a field in a subform for their pay rate as it
relates to a particular event. I'm trying to set it up so that the default
in that pay rate field comes up as the employees current pay rate, but I seem
to be striking out. I've been trying to write an expression for the default
value property of the payrate field that points to the employees current pay
rate, but can't seem to figure it out.

Any help? Please?

Thanks!
 
Krissie,

Thanks for the further explanation.

Try something along these lines on the After Update event of the
Employee combobox...
Me.Pay_Rate = Me.Employee.Column(1)
 
Back
Top