By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,475 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,475 IT Pros & Developers. It's quick & easy.

conditional default value in a table / form

P: 3
amongst the columns in my table are 2 - "Purchased" and "Unprompted", what I would like to do is:

If Purchased = Yes then Unprompted = Yes
If Purchased = No then Unprompted could be Yes or No, which can then be set by the user.

My thinking was I could set the default value of Unprompted to be =IIF([Purchased]=Yes,Yes, No). I would then be able to override it for any Purchased=No, Unprompted = Yes results.

If I can't achieve this directly within the table design do you know of any other means, possibly through a form control?
Jan 4 '07 #1
Share this Question
Share on Google+
3 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
amongst the columns in my table are 2 - "Purchased" and "Unprompted", what I would like to do is:

If Purchased = Yes then Unprompted = Yes
If Purchased = No then Unprompted could be Yes or No, which can then be set by the user.

My thinking was I could set the default value of Unprompted to be =IIF([Purchased]=Yes,Yes, No). I would then be able to override it for any Purchased=No, Unprompted = Yes results.

If I can't achieve this directly within the table design do you know of any other means, possibly through a form control?
You cannot do it in table design.

However if you have a form based on the table then in the after update event of the [Purchased] control you could put the following code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Purchased_AfterUpdate()
  2.  
  3.    If Me.Purchased = -1 Then ' this assumes that Purchased is a checkbox
  4.       Me.Unprompted = -1
  5.    Else
  6.       Me.Unprompted = 0
  7.    End If
  8.  
  9. End Sub
  10.  
Jan 5 '07 #2

P: 3
Thanks - that worked fine on the form, will keep this one safe - can see further uses for it..
Jan 5 '07 #3

NeoPa
Expert Mod 15k+
P: 31,186
That would set a good 'running' default for [Unprompted].
If you want to leave its pre-existing value when [Purchased] is set to No but set it to Yes when [Purchased] is set to Yes then :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Purchased_AfterUpdate()
  2.     If Me.Purchased Then Me.Unprompted = True
  3. End Sub
Robert Masters I presume?
Jan 5 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.