Assigning OpenArgs to field error

K

kdw

On the BeforeUpdate event of the main form I have:

DoCmd.OpenForm "frmTransaction", , , , acFormAdd, , Me.EmployeeNum

In the form_Open of the frmTransaction I have:

Me.EmployeeNum.Value = Forms!frmTransaction.OpenArgs

but I get a run-time error 2448: You can't assign a value to this object.
What is wrong?

You all have been great in helping me solve all sorts of problems. I know I
won't be disappointed. Thanks in advance!
 
A

Allen Browne

Is EmployeeNum an autonumber? If so, you won't be able to assign a value.

Is is a calculated expresssion? Bound to a calculated query field?

Is the source for the form a read-only query?

Is the record in your current form saved? Is EmployeeNum assigned? Might it
be null, e.g. if the form was at a new record?

Was frmTransaction already open? If so, the OpenArgs will be the one from
when it is originally opened, so may be a null or zero-length string or
other value that cannot be assigned to a number.

Does frmTransaction have its AllowAdditions property set to no?

That should be enough for starters, but that's the kind of thing you are
looking for.
 
D

Dirk Goldgar

kdw said:
On the BeforeUpdate event of the main form I have:

DoCmd.OpenForm "frmTransaction", , , , acFormAdd, , Me.EmployeeNum

In the form_Open of the frmTransaction I have:

Me.EmployeeNum.Value = Forms!frmTransaction.OpenArgs

but I get a run-time error 2448: You can't assign a value to this
object. What is wrong?

You all have been great in helping me solve all sorts of problems. I
know I won't be disappointed. Thanks in advance!

The form's Open event is too soon to assign a value to one of its bound
controls. Move that line of code to the form's Load event. If it
doesn't work there, then check out the other areas Allen Browne
suggested.
 
K

kdw

This solved the problem. I did go through the suggestions that Allen made as
well but my problem wasn't a result of any of those areas. Nevertheless, I
now know what to keep watching out for. Thank you both.
 
Top