Results 1 to 8 of 8
  1. #1
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    211

    Print Custom Header for Reports

    I have a series of reports and want to print the companies header with each report.



    I have a table (<Company Header>) with accommodating form (<Company Header>) that allows different entities to add their own customized header for when they print reports.

    Each form has a print button that opens a report in order to print the data of the current view. When the print button on the form is clicked each current view should print with customized header from a different table/form (<Company Header>) added to the top of the report.

    Right now I have the fields of the table/form (<Company Header>) added to one report but does not populate. The Control Source for each field is set to the table (<Company Header>) but says to enter a parameter value while displaying the source table's name. It says the table does not exist when I double checked by setting it up with the Expression Builder and navigating to the table and each subsequent field myself.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Cannot reference table object directly in textbox. The [Company Header] table would have to be included in the form or report RecordSource then bind textbox to field or use DLookup() in textbox ControlSource.

    Advise not to use spaces in naming convention.
    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
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    211
    Thanks June 7, I will give the DLookup a try. The space was just to denote the company header form and table. No spaces in any of my names - field or otherwise.

  4. #4
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    211
    I got it to work.

    There is a form and table. The table holds the data for the form that is customized to each customer that uses it in their enterprise.

    I added VBA to the report. Here is the VBA pasted into each reports coding.

    Code:
    Private Sub Report_Load()
        Me![txtCompanyHeaderCompanyName] = DLookup("CompanyHeaderName", "tblACompanyHeader", "CompanyName" <> "")
        Me![txtCompanyHeaderStreet] = DLookup("CompanyHeaderStreet", "tblACompanyHeader", "CompanyStreet" <> "")
        Me![txtCompanyHeaderCity] = DLookup("CompanyHeaderCity", "tblACompanyHeader", "CompanyCity" <> "")
        Me![txtCompanyHeaderState] = DLookup("CompanyHeaderState", "tblACompanyHeader", "CompanyState" <> "")
        Me![txtCompanyHeaderPostal] = DLookup("CompanyHeaderPostal", "tblACompanyHeader", "CompanyPostal" <> "")
        Me![txtCompanyHeaderCountry] = DLookup("CompanyHeaderCountry", "tblACompanyHeader", "CompanyCountry" <> "")
        Me![txtCompanyHeaderOfficePhone] = DLookup("CompanyHeaderOfficePhone", "tblACompanyHeader", "CompanyOfficePhone" <> "")
        Me![txtCompanyHeaderWebsite] = DLookup("CompanyHeaderWebsite", "tblACompanyHeader", "CompanyWebsite" <> "")
    End Sub

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Don't really need VBA. DLookup expression can be in textbox ControlSource property.

    If the table has only 1 record, don't need WHERE CONDITION argument. In fact, I am surprised they even work with that criteria structure.
    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
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    211
    Quote Originally Posted by June7 View Post
    I am surprised they even work with that criteria structure.
    It does work and it was giving me errors before when I tried DLookup in Control Source even without the WHERE Condition.

    This is the same working code without the WHERE Condition and it works as well.

    Code:
    Private Sub Report_Load()
        Me![txtCompanyHeaderCompanyName] = DLookup("CompanyHeaderName", "tblACompanyHeader")
        Me![txtCompanyHeaderStreet] = DLookup("CompanyHeaderStreet", "tblACompanyHeader")
        Me![txtCompanyHeaderCity] = DLookup("CompanyHeaderCity", "tblACompanyHeader")
        Me![txtCompanyHeaderState] = DLookup("CompanyHeaderState", "tblACompanyHeader")
        Me![txtCompanyHeaderPostal] = DLookup("CompanyHeaderPostal", "tblACompanyHeader")
        Me![txtCompanyHeaderCountry] = DLookup("CompanyHeaderCountry", "tblACompanyHeader")
        Me![txtCompanyHeaderOfficePhone] = DLookup("CompanyHeaderOfficePhone", "tblACompanyHeader")
        Me![txtCompanyHeaderWebsite] = DLookup("CompanyHeaderWebsite", "tblACompanyHeader")
    End Sub

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Those exact DLookup expressions should work in textbox. Just be sure to use = sign.
    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.

  8. #8
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    211
    They did not work in Control Source fields for some reason, not a big deal I prefer to put code in VBA for troubleshooting because it is a pain to sort through an error with multiple forms of code entered throughout MS Access.

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

Similar Threads

  1. Custom label print report
    By jabarlee in forum Reports
    Replies: 6
    Last Post: 11-01-2018, 05:47 AM
  2. Form | Do not print header
    By researchRE in forum Forms
    Replies: 1
    Last Post: 10-23-2018, 11:23 AM
  3. Help! Header Logo Image on form won't print.
    By DjMorgan in forum Access
    Replies: 8
    Last Post: 04-29-2013, 06:46 AM
  4. How to print custom-sized labels
    By jdorin in forum Access
    Replies: 1
    Last Post: 03-01-2013, 12:40 PM
  5. Info in header in Print Preview but now when Printed
    By 2012accessnoob in forum Reports
    Replies: 6
    Last Post: 02-16-2012, 02: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