Results 1 to 3 of 3
  1. #1
    XP_2600 is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Feb 2017
    Posts
    5

    Using name from filed as a report file name

    I am exporting a report from access as rtf, i would like to get it named automatically based on a filed in table, is that possible? i tried to use export with formatting
    output file:


    there is option to build expression but it seems not working, is that possible or i must do it using vba ? thanks.
    Click image for larger version. 

Name:	dr.png 
Views:	17 
Size:	16.7 KB 
ID:	27590

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    it doesnt work that way.
    you cant put variables in the macro, BUT you can in code.
    instead of macro, use vb:

    Code:
    sub btnPrint_click()
    vFile = "c:\folder\" & Format(date,"dd-mm-yyyy") & forms!myForm!PatientName & ".rtf"
    docmd.OutputTo  acOutputReport ,"rptMyReport",acFormatRTF,vFile
    end sub

  3. #3
    XP_2600 is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Feb 2017
    Posts
    5
    Quote Originally Posted by ranman256 View Post
    it doesnt work that way.
    you cant put variables in the macro, BUT you can in code.
    instead of macro, use vb:

    Code:
    sub btnPrint_click()
    vFile = "c:\folder\" & Format(date,"dd-mm-yyyy") & forms!myForm!PatientName & ".rtf"
    docmd.OutputTo  acOutputReport ,"rptMyReport",acFormatRTF,vFile
    end sub
    Thank you its worked perfectly .

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

Similar Threads

  1. Replies: 13
    Last Post: 12-12-2013, 07:22 PM
  2. Linking three filed to one
    By LukeJ Innov in forum Access
    Replies: 6
    Last Post: 04-25-2013, 12:40 PM
  3. Sum one filed based on its contsest
    By BorisGomel in forum Access
    Replies: 2
    Last Post: 03-29-2012, 03:01 PM
  4. Query: Two tables With Yes/No Filed
    By Judasdac in forum Queries
    Replies: 6
    Last Post: 10-17-2011, 12:24 AM
  5. Sum of a categorized filed
    By Costa in forum Reports
    Replies: 0
    Last Post: 02-24-2010, 07:34 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