Results 1 to 4 of 4
  1. #1
    Abdulaym is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2023
    Posts
    33

    subform and Report

    Trust we are all doing great?


    I have the following
    Report Name= rpt_invoice
    Subform name/source object= frmSales
    Form record Source= tblCusromers

    I want my report to display the current Customer_ID in my form in my Report so as to print it out. the below codes was used but I keep on getting error msg. please am new in ms access. I really need help

    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.OpenReport "rpt_invoice", acViewPreview, , "[Customer_ID] = " &
    [Customer_ID]

    Thanks

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    All that stuff at the beginning looks like you are thoughtful about some details. This is of no help at all
    I keep on getting error msg.
    Provide the error number and/or description (never just the error number). If you show code about an error make sure you identify the line that causes the error. Now to your question:
    Is Customer_ID text data type or is it number data type? If text, try
    DoCmd.OpenReport "rpt_invoice", acViewPreview, , "[Customer_ID] = '" & [Customer_ID] & "'"
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Abdulaym is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2023
    Posts
    33
    Thanks for your response sir
    The Customer_ID is AutoNumber sir

    when I typed my code the second line display error like this:

    Compile error:
    Expected: Expression

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I wouldn't use line breaks in case there's an unwanted space in your code, or at least I'd copy and paste into code tags here. If there are any extra spaces, the forum would likely strip it out when not in code tags and we wouldn't see it as a problem. Since you say that CustomerID is an autonumber, all I can suggest is to try
    DoCmd.OpenReport "rpt_invoice", acViewPreview, , "Customer_ID = " & Customer_ID

    Note that I also eliminated the brackets. Don't have time to check now but they may be causing your field name to be interpreted as [Customer_ID] and not Customer_ID. You don't need them anyway because there are no spaces in your field name.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Subform won't display in report
    By jessicamosby in forum Access
    Replies: 1
    Last Post: 07-09-2014, 07:51 AM
  2. Sorting a subform within a Report help
    By Lorlai in forum Reports
    Replies: 4
    Last Post: 03-21-2013, 08:11 AM
  3. Pass Subform filter to subform in report
    By camftm in forum Programming
    Replies: 16
    Last Post: 07-19-2011, 07:12 AM
  4. Add Subform to Report
    By tyguy in forum Reports
    Replies: 1
    Last Post: 05-05-2011, 11:36 PM
  5. Need help in subform and report
    By archie in forum Access
    Replies: 10
    Last Post: 09-10-2009, 10:10 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