473,395 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to add to 2 field names to a title when exporting to pdf

547 512MB
i get the title of the pdf right using the current date but not when i add 2 field names to the code.The code also export the file to the desktop.
This is my problem
Expand|Select|Wrap|Line Numbers
  1. strReportName = [Forms]![stocktakef]![FacilityName] + "-" & [Forms]![stocktakef]![StockDate] + ".pdf"
Expand|Select|Wrap|Line Numbers
  1.  Dim strUserName As String, strPath As String
  2. Dim strReportName As String
  3. strUserName = Environ("username")
  4.              strReportName = [Forms]![stocktakef]![FacilityName] + "-" & [Forms]![stocktakef]![StockDate] + ".pdf"
  5.              'strReportName = [Forms]![stocktakef]![FacilityName] + "-" & Format(Date, "dd-mm-yyyy") + ".pdf"
  6.          strPath = "C:\Users\" & strUserName & "\desktop\" & strReportName
  7.         DoCmd.OutputTo acOutputReport, "rptStocktake", acFormatPDF, strPath, False
  8.  
Any suggestions please?
Jul 5 '13 #1
4 1306
Seth Schrock
2,965 Expert 2GB
We need to know exactly what you are getting along with the values for each of the controls. It would also help if you would put a debug.print strReportName right before line 6 so that we know what exactly is getting put together.
Jul 5 '13 #2
Rabbit
12,516 Expert Mod 8TB
Why are you using + in one instance but & in another? Just so you know, & is the string concatenation operator.
Jul 6 '13 #3
neelsfer
547 512MB
i get the runtime error 13 mismatch with my code. The stockdate field is an unbound textbox. The current date string works 100% but i would prefer the actual stocktake date to be added in the title of the pdf file, from the stockdate txtbox.
Jul 6 '13 #4
Seth Schrock
2,965 Expert 2GB
As you are dealing with dates, it is possible that the plus sign (+) might be causing it to actually try to perform addition instead of just concatenating it as a string.

See Combining all parts of a name without extra spaces for more information about the plus sign vs the ampersand and how they work in VBA and SQL.
Jul 6 '13 #5

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

Similar topics

7
by: JDS | last post by:
Hi, all. I'd like to do the following, preferably *without* resorting to JavaScript: I have a long, dynamically-generated form questionnaire. Not all of the form fields are dynamically...
1
by: Jacky11 | last post by:
Can anyone help me? Please see the code I'm using now. Public Function sheetlayout() On Error GoTo Err_Command1_Click Dim xl As Object Set xl = GetObject("c:\windows\desktop\123.csv")...
2
by: Michael Bulatovich | last post by:
I have a simple db to keep track of work/time/projects etc. It has two fields (column) named "start time" and "end time" WITH THE SPACES. I'm trying to do some automation to a form associated with...
6
by: HD | last post by:
Hello. For the following, I would appreciate if anyone could tell me: if it can be done, how it might done, and/or what search terms I could use to find the solution myself. I would like to...
3
by: Billy | last post by:
I do a SELECT * from table command in an ASP page to build a text file out on our server, but the export is not to allow a field name rows of records. The first thing I get is a row with all the...
1
by: Billy | last post by:
I do a SELECT * from table command in an ASP page to build a text file out on our server, but the export is not to allow a field name rows of records. The first thing I get is a row with all the...
4
by: | last post by:
Given an XML file (dataset.writexml), here is my output (simplified for this posting): <?xml version="1.0" standalone="yes"?> <NewDataSet> <Category> <CategoryId>80</CategoryId>...
3
by: myemail.an | last post by:
Hi all, I use Access 2007 and have come across this error a number of times. I have two tables (customer information) which should contain - ideally - the same data. I create a query to compare...
2
by: myemail.an | last post by:
Hi all, I need to export a table from Ms Sql to Access. However, dts import/ export gives me an error because the field names are too long. Is there a quick way to trim the names of all fields...
1
by: rotsjke | last post by:
Hi, i need to process a onix xml file. I use microsoft dom and this works, except for the fact that there are dupicate field names in this onix file and while processing this file each one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.