Results 1 to 5 of 5
  1. #1
    AccessForumUser is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2017
    Posts
    19

    What's up with my code!? Need to BLANK a text box based on a NULL value of another one

    hello,

    I have a date range query which runs fantastic on my report.
    Now, I have a field called "CaseNum" with a data type Short Text, and another field called "OtherNotes" which is a Short Text data type as well.
    In my "On Load" located in the report, I have the following code:

    If IsNull(Me.OtherNotes) = True Then
    Me.CaseNum.Visible = False
    Else
    Me.CaseNum.Visible = True
    End If

    - So i'm saying, if OtherNotes is blank, then blank out the CaseNum which it's doing, but it's also blanking out the results that have OtherNotes as well..

    What I'd like to do is if there is NO notes entered in the OtherNotes field, then do NOT show the CaseNum.

    On my report I've got the CaseNum and OtherNotes Label in the "Page Header" area, and the text boxes for both in the "detail" section, so it shows up in a nice column when displayed.

    The problem i'm seeing is that there are blank CaseNum when there are populated OtherNotes..


    The other problem is that lets say there was 15 records during the data range search.. I get 15 lines on my report regardless if there is anything in them.

    Help!!! - Thanks!

    If i change the first line to "If Me.OtherNotes = "" Then", I get all the CaseNum populated.,
    I also checked the Can Shrink and changed it to Yes

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Why do all that on the report and not simply move it to the query :CaseNum: iif(isnull([OtherNotes]),Null,[CaseNum])

    Cheers,
    Vlad

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,424
    - So i'm saying, if OtherNotes is blank, then blank out the CaseNum which it's doing, but it's also blanking out the results that have OtherNotes as well..
    learn about the order of events. The load event is performed once, so your code is only working on the first record.

    you need to use an event (probably the format event) in the section where your controls are located

  4. #4
    AccessForumUser is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2017
    Posts
    19
    Amazing! Thanks for your help Vlad. And thanks to everyone who takes the time to read and help others out on this forum. I am truly grateful.
    I never thought to look at it that way.. thanks again

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Glad it worked. Please mark the thread as solved if you think we are done here.
    Vlad

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 06-30-2016, 10:51 AM
  2. Hide report label when text box is null/blank
    By crsport3 in forum Access
    Replies: 7
    Last Post: 10-30-2013, 07:14 AM
  3. Replies: 9
    Last Post: 08-19-2013, 01:08 PM
  4. Importing text file with blank fields changes to null
    By Egoyret in forum Import/Export Data
    Replies: 9
    Last Post: 11-10-2011, 01:51 PM
  5. code for blank text ???
    By alex_raju in forum Access
    Replies: 1
    Last Post: 08-02-2011, 07:50 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