Results 1 to 4 of 4
  1. #1
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234

    Add IF statement to report field.

    Attached is a picture of my Special Event Report Sheet, (SERS). The field "Client" takes its data from tblClient, EntityName. I want to tell it "If entity name is null, then use ContractingPartyContactID from tblEvent."



    Where/how do I do that?

    Also, when I told it to use only ContractingPartyContactID, it used the ID number instead of the name of the contact. How can I change that?

    Thank you.

    Click image for larger version. 

Name:	SERS.png 
Views:	10 
Size:	51.1 KB 
ID:	22983

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    have an unbound text box txtName, to show the result
    in the ONCURRENT event of the form
    put the if to show the needed item


    Code:
    sub form_OnCurrent()
    if isnull(EntityName) then
      txtName = ContractingPartyContactID
    else
      txtName = EntityName
    end sub

  3. #3
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    ONCURRENT is not an option on the property sheet under the Event tab.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Presuming both fields are in the source query, you can use the Nz() function.

    To your second question, in the source query you would join the two tables on the ID field, enabling you to return the text field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Help with If Statement in Access Report
    By jpfulton248 in forum Reports
    Replies: 1
    Last Post: 08-05-2015, 09:57 AM
  2. field statement with if then else
    By darwin in forum Queries
    Replies: 18
    Last Post: 05-15-2015, 02:36 PM
  3. Replies: 3
    Last Post: 05-06-2013, 03:03 PM
  4. Help with if statement in report
    By Nixx1401 in forum Reports
    Replies: 1
    Last Post: 07-02-2010, 07:43 AM
  5. If Statement in Report
    By Nixx1401 in forum Reports
    Replies: 3
    Last Post: 07-01-2010, 04:14 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