Referring to another field in the same table

G

Guest

Is it possible to refer to a field in another table to set the default value?

I am trying to set up a default value for a field in a table. I am referring
to another field in a different table. This is my calc:

=("AB" &[Table1]![Field2]& (Format(Date(),"mmyy")))

I receive this error when trying to save the table:

Could not find field "[Table1]![Field2]. (Error 3799)
 
A

Allen Browne

No. That won't work.

Access assigns the Default Value *before* any of the fields have received an
entry, so you cannot use the entry in another field as your default value.

Instead, you could use the AfterUpdate event of each control on your form
that this depends on.
 
F

fredg

Is it possible to refer to a field in another table to set the default value?

I am trying to set up a default value for a field in a table. I am referring
to another field in a different table. This is my calc:

=("AB" &[Table1]![Field2]& (Format(Date(),"mmyy")))

I receive this error when trying to save the table:

Could not find field "[Table1]![Field2]. (Error 3799)

You would use DLookUp.
I'll guess that Table1 has only the one record, as I don't see any
criteria in your sample.

="AB" & DLookUp("[Field2]","Table1") & Format(Date(),mmyy"))

If the value of Field2 is 678 the result will appear as AB6780706.
 

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