Print form view information into a report and then extract to word in one process

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nicholas Davenport
    New Member
    • Aug 2010
    • 18

    Print form view information into a report and then extract to word in one process

    Hi, I hope someone can help!

    I have a finance form where the information is manually completed by agents, I would like it so that when the agents click finish to add a new record, the details that have just been completed will automatically print off and while at the same time the information is also stored for our records as a back up on our server. I have seen this process working, so I have tried to replicate it myself but I seem to be getting a mismatch type error and it's driving me insane. Would someone be able to check my code and help me with where I’m going wrong.....Thank s in advance for your time, it's appreciated

    I have attached the code in a word document, The code I'm struggling with is highlighted in Bold....Thanks
    Attached Files
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    Do you have the following set at the top of your module:
    Code:
    Option Compare Database
    Option Explicit
    Have you done a compile from the debug menu?
    Would you also post the actual string returned from "FileName ="? (if you're steping thru the code...you can press <ctrlG> and then type ?Filename)
    and finally...
    place a stop command on a line below the "DIM" statments and [F8] thru your code until you get the error. It would be helpfull to know exactly which line is causing the error.

    -z
    Last edited by zmbd; Aug 14 '12, 05:46 PM. Reason: added <ctrlG> etc..

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      For your sanity...

      When nameing directories (folders), files, forms, tables, fields, queries, or what have you; it is better not to use any spaces, specical charaters, etc... instead, it is a best practice to use only the underscore and alphanumeric charactors in these names.

      For example your code (using just what you have):
      Code:
      FileName = ID & " " + CustomerName & " " + Registration & " - " & ReportName & DocType
      would evaluate to something like (assuming there are no null values):
      "ID CustomerName Registration - ReportNameDocTy pe"
      if there are nulls then you get: " - " =
      "(null)(space)( null)(space)(nu ll)(space)(-)(null)(null)"
      or if the "docType" is set " - .DOC"

      Now I know that the current operating systems will allow this; however, when you go to search for the file later... good luck.

      You'll find that queries on tables and fields that include spaces will also be much more difficult to write...

      -z

      Comment

      • twinnyfo
        Recognized Expert Moderator Specialist
        • Nov 2011
        • 3662

        #4
        Nick,

        Just reviewing your FINISH_Click Sub, it does not look (on the surface) that your error is starting in the code. There might also be a data type mismatch in the underlying data of the report, whihc would cause the the error to trip at that point, as well.

        In additioni to Z's advice, try running the report's underlying query by itself to see if it functions properly.

        Comment

        • Nicholas Davenport
          New Member
          • Aug 2010
          • 18

          #5
          Thanks to both of you for your quick replies, I've been out of the office today, but will have a look over your suggestions tomorrow. I'll double check the Option Compare Database & Option Explicit and run through the d-bug to obtain the error line, and I'm quite confident the report pulls all the correct information/data through into the correct fields I've selected within the report, but I'll double check, again, thanks very much for your time, it's appreciated

          Comment

          Working...