Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    jre1229 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    30

    Querying All Data When Form Field Is Blank


    I have a report that is feeding from a query. The query using criteria from my form with the following code:
    Code:
    IIf([Forms]![frmBids]![BidDateSelection]="","7/19/2012",[Forms]![frmBids]![BidDateSelection])
    What I am trying to do, is have the "BidDateSelection" set to 7/19/2012 when the field is blank but my code does not work. I have tried using "" and Null but neither work. Does anyone know what the field value is when there is no entry?

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If you used "[Forms]![frmBids]![BidDateSelection]= NULL", it will always return False. Nothing is equal to NULL, not even NULL...

    Try this:
    Code:
    IIf(Len(Trim([Forms]![frmBids]![BidDateSelection] & ""))= 0,"7/19/2012",[Forms]![frmBids]![BidDateSelection])

  3. #3
    jre1229 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    30
    Quote Originally Posted by ssanfu View Post
    If you used "[Forms]![frmBids]![BidDateSelection]= NULL", it will always return False. Nothing is equal to NULL, not even NULL...

    Try this:
    Code:
    IIf(Len(Trim([Forms]![frmBids]![BidDateSelection] & ""))= 0,"7/19/2012",[Forms]![frmBids]![BidDateSelection])
    I tried this but it said "This expression is typed incorrectly, or it is too complex to be evaluated".

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I should learn to read better.

    In a query, you don't refer to a control on a form, but to a field in the query (in this instance). For criteria in a query, you can refer to a control on a form.
    So the column in the query should be:
    Code:
     SomeName:IIf(Len(Trim([BidDateSelection] & ""))=0,"7/19/2012",[BidDateSelection])
    Change "SomeName" to what you want the column name to be.

  5. #5
    jre1229 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    30
    Quote Originally Posted by ssanfu View Post
    I should learn to read better.

    In a query, you don't refer to a control on a form, but to a field in the query (in this instance). For criteria in a query, you can refer to a control on a form.
    So the column in the query should be:
    Code:
     SomeName:IIf(Len(Trim([BidDateSelection] & ""))=0,"7/19/2012",[BidDateSelection])
    Change "SomeName" to what you want the column name to be.

    I'm a little confused. I understand that I need to add that as a new column, which I did as below:

    Code:
    SomeName: IIf(Len(Trim([Forms]![frmBids]![BidDateSelection] & ""))=0,"7/19/2012",[Forms]![frmBids]![BidDateSelection])
    But then do I have to set my original field, which is BidDate, equal to "SomeName" in order to get the query to pull the selected date?

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    No..
    Remove the references to the form. You can't reference the form. Reference the field in the query

    Code:
    BidDate:IIf(Len(Trim([BidDateSelection] & ""))=0,"7/19/2012",[BidDateSelection])

  7. #7
    jre1229 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    30
    Quote Originally Posted by ssanfu View Post
    No..
    Remove the references to the form. You can't reference the form. Reference the field in the query

    Code:
    BidDate:IIf(Len(Trim([BidDateSelection] & ""))=0,"7/19/2012",[BidDateSelection])
    So how do I pass the value from the for to "BidDateSelection"? It pops up with a prompt wanting an entry but I want the entry to come from the form.

  8. #8
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    So how do I pass the value from the for to "BidDateSelection"? It pops up with a prompt wanting an entry but I want the entry to come from the form.
    I am not understanding what you are trying to do.

    So:
    You have a report.
    The row source for the report is a query.
    The query has a field named "BidDateSelection".
    It has a date or is NULL.

    For each record returned in the query:
    In a new column in the query, if the field "BidDateSelection" is NULL, then you want a date entered of "7/19/2012".
    If
    the field "BidDateSelection" is NOT NULL, then the date in the new column should be the date in the field "BidDateSelection".

    Is this correct?

  9. #9
    jre1229 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    30
    Not really. Let me walk through it.
    I have a report
    The row source for the report is a query
    The query has a field named "BidDateSelection"
    This field has a date, there are no NULL fields

    I then have on my form a date picker
    I was using 7/19 as a place holder but what would be better is if the date picker is left blank, for it to pull all records
    Otherwise it would pull the date selected.

    Quote Originally Posted by ssanfu View Post
    I am not understanding what you are trying to do.

    So:
    You have a report.
    The row source for the report is a query.
    The query has a field named "BidDateSelection".
    It has a date or is NULL.

    For each record returned in the query:
    In a new column in the query, if the field "BidDateSelection" is NULL, then you want a date entered of "7/19/2012".
    If
    the field "BidDateSelection" is NOT NULL, then the date in the new column should be the date in the field "BidDateSelection".

    Is this correct?

  10. #10
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I then have on my form a date picker
    What is the name of the date picker control? If it is "BidDateSelection', change it to something else.

  11. #11
    jre1229 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    30
    Quote Originally Posted by ssanfu View Post
    What is the name of the date picker control? If it is "BidDateSelection', change it to something else.
    It is called "BidDateSelector", I'm completely confused. I attached a stripped down version of my DB. Use the shift key to open it and look at the frmBids form. There is a date and vendor on the bottom right, this is where I am trying to do this.
    Attached Files Attached Files

  12. #12
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I have A2K/A2K3 and can't open the attached accmdb.
    Try this:
    Code:
    SomeName:IIf(Len(Trim([[Forms]![frmBids].[BidDateSelector] & ""))=0,"7/19/2012",[BidDateSelection])


  13. #13
    jre1229 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    30
    Quote Originally Posted by ssanfu View Post
    I have A2K/A2K3 and can't open the attached accmdb.
    Try this:
    Code:
    SomeName:IIf(Len(Trim([[Forms]![frmBids].[BidDateSelector] & ""))=0,"7/19/2012",[BidDateSelection])

    All I get is an error saying invalid bracketing on the BidDateSelector

  14. #14
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725

  15. #15
    jre1229 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    30
    Quote Originally Posted by jre1229 View Post
    All I get is an error saying invalid bracketing on the BidDateSelector

    Nope, it asks me to enter the parameter again.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Copy data into a blank field
    By winterh in forum Database Design
    Replies: 2
    Last Post: 04-16-2012, 04:57 AM
  2. Querying Treaty Data
    By ohthesilhouettes in forum Queries
    Replies: 1
    Last Post: 06-15-2011, 11:13 AM
  3. Replies: 4
    Last Post: 05-11-2011, 03:06 AM
  4. Adding field to form causes blank view.
    By emccalment in forum Access
    Replies: 1
    Last Post: 04-02-2010, 06:27 PM
  5. Replies: 1
    Last Post: 03-15-2009, 04:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums