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

Help on Access Expression

P: 19
Can someone tell me why this expression doesn't work in the build function of a form? Can a date be null? Check5 is a check box.
Expand|Select|Wrap|Line Numbers
  1. =IIf([Check5]=0,[received_date]=Null,Date())
Thank you for the help.
Aug 28 '08 #1
Share this Question
Share on Google+
9 Replies


NeoPa
Expert Mod 15k+
P: 31,494
What do you mean doesn't work?

Certainly to determine if something holds a Null value or not is done differently within VBA and SQL. Neither uses the equality operator (=).

Perhaps if you could explain what you're trying to we could be more help. As it stands it looks like you are trying to assigne (rather than return) a value within the True part of the IIf() function - which makes no sense.
Aug 28 '08 #2

NeoPa
Expert Mod 15k+
P: 31,494
On closer inspection, the initial "=" would indicate SQL code within a query. In that case to determine if a value is Null you would use "x Is Null", but this still doesn't explain what you're intending to get from this.
Aug 28 '08 #3

P: 19
I am trying to say, if check box, Check5, is not checked then the field "recieved_date" is null else todays date. Am I totally doing this wrong? Does this help you?
Aug 28 '08 #4

P: 19
In other words, if the check box isnít checked then I donít want a date in the received_date field, if the check box is checked then I do want todays date in the received date_field.
Aug 28 '08 #5

NeoPa
Expert Mod 15k+
P: 31,494
Pretty well yes :(

Is this formula to be entered into the field [Received_Date] in the query?

If so, then use this :
Expand|Select|Wrap|Line Numbers
  1. =IIf([Check5],Date(),Null)
If not, then you'll need to explain how [Received_Date] fits in.
Aug 28 '08 #6

P: 19
This formula is to be added to the check5 box ďcheck boxĒ on lost focus in the properties. If the box is check then I want todays date to appear in the received_date box, if itís not checked then I want received_date to be blank with no date. So the check box comes first then the date box.
Aug 28 '08 #7

NeoPa
Expert Mod 15k+
P: 31,494
If I understand you correctly then you're actually looking for the following code.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Check5_AfterUpdate()
  2.   Me.Received_Date = IIf(Me.Check5,Date(),Null)
  3. End Sub
NB. This would be in the AfterUpdate event procedure (not lost focus and not properties).
Aug 28 '08 #8

P: 19
Thank you very much, that works.
Aug 29 '08 #9

NeoPa
Expert Mod 15k+
P: 31,494
It's a pleasure to Help :)
Aug 29 '08 #10

Post your reply

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