473,378 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

conditional default value in a table / form

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
3 3545
MMcCarthy
14,534 Expert Mod 8TB
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
Thanks - that worked fine on the form, will keep this one safe - can see further uses for it..
Jan 5 '07 #3
NeoPa
32,556 Expert Mod 16PB
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

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

Similar topics

8
by: neblackcat | last post by:
Would anyone like to comment on the following idea? I was just going to offer it as a new PEP until it was suggested that I post it here for comment & consideration against PEP 308. I'm far...
3
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be...
13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
0
by: Paul T. Rong | last post by:
I don't know why that I lost track of the post. I found it from the newsgroup and paste last two posts. Pieter Linden said: "To do this - use conditional formatting..." I didn' work it out....
7
by: Shaldaman | last post by:
I have an Access form called "Login". "Command10" is a button on the form and "Text5" is a text field on it. When a user enters a value in the Text5 text field and clicks the button Command10, I...
0
by: GGerard | last post by:
Hello With MSAccess 2000, I have created a program with forms and applied some Conditional Formatting on some of the text box.
2
by: mukesh | last post by:
Can we use expression in default value for a table field for example – IIf(Table-1.field-1=table-2 . field-1, table-1.field-2, 0) Interpretation – If field-1 of table -1 is like/equal to...
2
by: Filips Benoit | last post by:
Dear All, Access 2003 adp on SQL_server 2005 A continious form showing 1 month based on table 'CALENDAR_MONTH_GRID' and fill with a SP. Fields: Companyname, Day1, day2, etc. The value in the...
2
by: robertng90025 | last post by:
I'm having a problem with MS Access 2003 and its conditional formatting. I have textboxes on a continuous form whose left and right margins are set to 0.03 inches. Based on each textbox's...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.