CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2006
    Location
    Baltimore, Maryland, USA
    Posts
    104

    Access Saved Forms [MS Access 2007]

    I'm trying and I'm not finding anything with my key words ("vba","report","reference","elements","").

    I'm attempting to create a form/report that will call another report (and it's form elements) I have saved in the database. I need to call these elements so I can pass data to them, programmatically. After I pass this data, I intend to print the report. Can this be done?

    1. How do I create a report/form object from a report already present in the DB?

    2. How can I call the form elements within a saved report in the DB?
    -= the best is yet to come =-

  2. #2
    Join Date
    Jan 2006
    Location
    Baltimore, Maryland, USA
    Posts
    104

    Re: Access Saved Forms [MS Access 2007]

    Code:
    Dim oReport As Report_rptName
    Set oReport = Report_rptName
    .
    .
    oReport.Text13.Value = "changed text by hand"
    .
    .
    DoCmd.OpenReport "oReport"

    this is what I have... I have a report saved in the database, "rptName".
    I want to programmatically populate the report's components, then open/print the report with the updated values I programmed.

    Looking at the code above, I'm trying to create an object so I can control it's components before printing. Using the editor, I see a list of Access Class Objects and one of them is the report I have created. My creation of a new object works (compiles without error) because, looking at the blue line, I was able to access and change the value of a textbox I have in the report, rptName.

    My trouble comes when I try to use said object. I need to print out the report with the changes/additions I made by hand in the code. The red line is the command statement to print out a report. My problem, I now have an object as my report and I need to make this object a report to print.

    When I reference the object, I get the following error message:
    ""An expression you entered is the wrong data type for one of the arguments""
    When I reference the object within quotes (as I would passing the name of the report as-is in the db), I get the following error message:
    ""The report name 'oReport' you entered in either the property sheet or macro is misspelled or refers to a report that doesn't exist""


    I can't figure out how to get this done, the way I want it done. With this additional information, can anybody understand and help me with this issue?
    -= the best is yet to come =-

  3. #3
    Join Date
    Aug 2009
    Posts
    100

    Re: Access Saved Forms [MS Access 2007]

    From what I can see, the problem lies within your DIM statement.

    Your DIM statement looks incorrect to me. You should have your DIM statement as

    Code:
    DIM oReport as New Object
    Then you can set oReport to whatever report it is that you're trying to use. Like so:

    Code:
    Set oReport = Report_rptName
    Last edited by Leon Kennedy; December 6th, 2010 at 02:41 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
  •  





Click Here to Expand Forum to Full Width

Featured