By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

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

P: 18
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.....Thanks 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
File Type: doc Private Sub cmdFINISH.doc (27.5 KB, 204 views)
Aug 14 '12 #1
Share this Question
Share on Google+
4 Replies


zmbd
Expert Mod 5K+
P: 5,397
Do you have the following set at the top of your module:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. 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
Aug 14 '12 #2

zmbd
Expert Mod 5K+
P: 5,397
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):
Expand|Select|Wrap|Line Numbers
  1. FileName = ID & " " + CustomerName & " " + Registration & " - " & ReportName & DocType
would evaluate to something like (assuming there are no null values):
"ID CustomerName Registration - ReportNameDocType"
if there are nulls then you get: " - " =
"(null)(space)(null)(space)(null)(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
Aug 14 '12 #3

twinnyfo
Expert Mod 2.5K+
P: 3,284
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.
Aug 14 '12 #4

P: 18
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
Aug 15 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.