Results 1 to 6 of 6
  1. #1
    jmitchelldueck is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    51

    Add string to expression in Control Source


    Hi,

    Is it possible for one to add a string of text to an Access expression in the control source of a report? For example, one of the defaults on a report is to display the date at which the report was created. Is there a way to say: "This report was created on " [Date] "at " [Time]?

    Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Use concatenation.

    = "This report was created on " & [Date] & " at " & [Time]?

    Date is a reserved word. Should not use reserved words as field names.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Yes, you would use the On Format event of the appropriate section.
    ="This report was created on " & Date & " at " & Now

  4. #4
    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,726
    You do not have to add anything in the reports recordsource. You could include the inherent function Now() -- to the control and that will provide the Date and Time in 1 string.
    If you want 2 separate strings then use Date() and Time().

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Yes, if you want the current date/time, not some values from a record, use date/time functions.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by June7 View Post
    Yes, if you want the current date/time, not some values from a record, use date/time functions.
    I was thinking fields too. After I posted, I read the literal strings included in the expression and figured the OP was wanting the function. I edited my post by removing the brackets at that point.

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

Similar Threads

  1. Replies: 6
    Last Post: 05-17-2015, 01:22 PM
  2. Control source Expression giving #Error
    By N3w2access in forum Forms
    Replies: 5
    Last Post: 01-21-2014, 07:53 AM
  3. Replies: 1
    Last Post: 08-13-2013, 10:06 AM
  4. Replies: 3
    Last Post: 04-30-2013, 05:32 AM
  5. Textbox Control Source As An Expression help!
    By emilyrogers in forum Forms
    Replies: 11
    Last Post: 02-11-2011, 07:31 AM

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