Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default table field value to depend on another field value

Status
Not open for further replies.

slames

Technical User
Nov 5, 2002
211
GB
I have a table with a list of subscriptions, if their subscription is of class "free", then I want the default value of status to equal active, otherwise I want the default of this field to be inactive. This is what I've put in the default field of the design of table but it causes errors,

IIf(([tblSubscription].[scClass])="2","1","3")

can anyone help?, Thanks
Steph
 
Unfortunately, Access does not allow cross-table field validation rules in schema design. The best you can do here is try to determine WHICH class of subscription is/will be most common, and set the default status to that code, and then through your form(s) or otherwise, change it when appropriate.

However, you might not even need to STORE a "status" field, if it can be directly derived from your "class" field - just compute it with an expression in a query when you need it.

In other words, why bother storing TWO things, that essentially have a one-to-one relationship:

Class Status
----- ------
Free Active
NotFree inActive


It would all depend on HOW MANY statuses a NON-free class of subscription could have.

You could also handle this with a look-up table as well.

Jim
Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top