473,387 Members | 1,582 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,387 software developers and data experts.

Specified file name not working

Hi apologies in advance if this has been asked before.

I have created a button in a form and its function

on click ( I have gone into the macro builder)

-ExportWithFormating
Object type - Form
Object name - (???)
Output format - PDF Format (*.PDF)

now heres the thing If I leave the object name blank it automatically tries to save the form into a pdf format with a default name "FrmMachinefault.pdf

and this works perfectly.

However if I tried to specify the name in anyway even a simple "file" it comes up with an error.

the code I want to put in is a macro to pull information from the existing form

= [Closed date] & "_" & [Effected area] & "_" & [Asset] & "_" & [Title].


The result should be for example.
02_07_15_101_Foundry_Mixer_Broken_Shaft.PDF

this is what I want and what it currently does is goes to the safe as page with the correct title but when I click SAVE it comes with

"Microsoft Access cannot find the object 'ǀ1'.
Make sure the object exists and that you spell its name correctly."

I have gone through the names over and over again and it should be correct please help
Jul 9 '15 #1
13 3264
jimatqsi
1,271 Expert 1GB
Isn't it because the object name that is being referred to is the object that should be exported, not the name of the resulting file. You could specify the name of any form or table or query.

Jim
Jul 9 '15 #2
Hi Jim, I think you are correct, I have changed it back to the correct Object name and it consistently work.

However, that doesn't fix my problem. I require it to pull information from the "opened" for the filename so when I click the export button, it will automatically pull the information I want as per the example and all I need to do is press save after I go into the location.
Jul 9 '15 #3
zmbd
5,501 Expert Mod 4TB
Which version of Office are you using?
ExportWithFormatting Macro Action
You should have the option to set the OutputFile

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-16" standalone="no"?>
  2.    <UserInterfaceMacros xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application">
  3.       <UserInterfaceMacro MinimumClientDesignVersion="14.0.0000.0000">
  4.          <Statements>
  5.             <Action Name="ExportWithFormatting">
  6.                <Argument Name="ObjectType">Form</Argument>
  7.                <Argument Name="ObjectName">frmQuery1</Argument>
  8.                <Argument Name="OutputFormat">PDFFormat(*.pdf)</Argument>
  9.                <Argument Name="OutputFile">C:\Users\ZMBD\documentname.pdf</Argument>
  10.             </Action>
  11.          </Statements>
  12.    </UserInterfaceMacro>
  13. </UserInterfaceMacros>
Jul 10 '15 #4
Currently using Office 2010

I have tried putting additional information in the OutputFile however when I start to put any sorts of code in there it errors on me.
Jul 10 '15 #5
zmbd
5,501 Expert Mod 4TB
Hmm... the limitations of Acc-Macro language.
What is the exact error when you attempt to build the string in the [OutputFile] parameter?
Is the string that you are attempting to use the one in the OP? (= [Closed date] & "_" & [Effected area] & "_" & [Asset] & "_" & [Title].
This will not work... the full path and correct file name, including extension (I know, says optional in the link; however, I suggest that it be included - saves on the head-pain), must be built (i.e: c:\directory1\directory2\filename.pdf). Refer to the link I posted on this function for details.

You could code a function to return the full path and file name.

You could use the tempvars (example macro here too) macro method, build your path, then use the tempvar in the output file


By way of example, the following works in my testing database (I have change the user path of course :) )
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-16" standalone="no"?>
  2. <UserInterfaceMacros xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application">
  3.     <UserInterfaceMacro For="Command10" Event="OnClick">
  4.         <Statements>
  5.             <Action Name="ExportWithFormatting">
  6.                 <Argument Name="ObjectType">Form</Argument>
  7.                 <Argument Name="ObjectName">frmQuery1</Argument>
  8.                 <Argument Name="OutputFormat">PDFFormat(*.pdf)</Argument>
  9.                 <Argument Name="OutputFile">="C:\Users\ZMBD\Documents\" &amp; [FieldNameOnForm] &amp; ".pdf"</Argument>
  10.             </Action>
  11.         </Statements>
  12.     </UserInterfaceMacro>
  13. </UserInterfaceMacros>
If you (toggle the numbers first) select the above and were to copy and paste it into a command button named Command10 in the on_click event as an embedded macro this will run,...

Two things to note, the actual text in the output file is:
="C:\Users\ZMBD\Documents\" & [FieldNameOnForm] & ".pdf"

AND

the entire form's record set is exported not just the current record... I haven't tried with a filter set either via the GUI, Macro, or VBA so I do not know if with the Macro action the filter would only export the filtered records.
Jul 10 '15 #6
What I have tried to put in the output file as


Expand|Select|Wrap|Line Numbers
  1. ="Z:\(P) Maintenance\Planned Maintenance\Jobs\" & [Closed date] & "_" & [Effected area] & "_" & [Asset] & "_" & [Title] &".PDF"
The error I get is

MS Access cant save the output data to the file you've selected.
Jul 13 '15 #7
NeoPa
32,556 Expert Mod 16PB
Can you post the resultant string. IE. The actual name you're trying to use as opposed to the formula which creates it.
Jul 14 '15 #8
@NeoPa

I don't understand sorry, what I am trying to get as an end result would be something like this.

PDF file name:
14_07_15_Foundry_Furnace_Faulty Electrics
[Closed date]_[Effected area]_[Asset]_[Title]

So if I was to see the end address of this file it would look like this.
Expand|Select|Wrap|Line Numbers
  1. Z:\(P) Maintenance\Planned Maintenance\Jobs\14_07_15_Foundry_Furnace_Faulty Electrics.PDF
I hope this was what you were after.
Jul 14 '15 #9
zmbd
5,501 Expert Mod 4TB
iPanterra : AFAIK: you can not use the parentheses " () " in a file name.

-It is best practice when naming fields, tables, and files to avoid the use of anything other than alphanumeric characters and the underscore (spaces although allowed are problematic from a programing point of view and best avoided) and it is VERY important to avoid all reserved words and tokens:
Access 2007 reserved words and symbols
AllenBrowne- Problem names and reserved words in Access


Neopa: iPanterra is in the Macro editor... stuck building the string in the function, which is a pet-peeve of mine as you well know ;-)

WITH THAT SAID... there is a workaround since Acc2010 that is the tempvars collection... great way to store session level information and to pass info between the Macro side of Access to the VBA side and to use in queries... one of the more useful tools MS added to the program (IMNSHO)!

iPanterra: To build the string, refer back to the settempvars links I gave earlier. Build your string there and then use the tempvar set in the macro.

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-16" standalone="no"?>
  2.     <UserInterfaceMacros xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application">
  3.     <UserInterfaceMacro For="Command10" Event="OnClick">
  4.         <Statements>
  5.             <Action Name="SetTempVar">
  6.                 <Argument Name="Name">savepath</Argument>
  7.                 <Argument Name="Expression">"C:\Users\ZMBD\Documents\" &amp; [Expr] &amp; ".pdf"</Argument>
  8.             </Action>
  9.             <Action Name="ExportWithFormatting">
  10.                 <Argument Name="ObjectType">Form</Argument>
  11.                 <Argument Name="ObjectName">frmQuery1</Argument>
  12.                 <Argument Name="OutputFormat">PDFFormat(*.pdf)</Argument>
  13.                 <Argument Name="OutputFile">=[TempVars]![savepath]</Argument>
  14.             </Action>
  15.             <Action Name="RemoveTempVar">
  16.                 <Argument Name="Name">savepath</Argument>
  17.             </Action>
  18.         </Statements>
  19.     </UserInterfaceMacro>
  20. </UserInterfaceMacros>
  21.  
To trouble shoot
Either insert a stopmacro action prior to, or
OMIT, lines 15,16,17 - these clean up the tempvars.
Cut and paste this in your macro editor for the control... (if not using the stop action then delete the removetempvar entry).
Run your code
Press <ctrl><g>
in the immediate window
type ?[tempvars]![savepath]
You will get the resolved string
C:\Users\ZMBD\Documents\Doe.pdf

Of course I've changed the path for this post :) however, you should get the ideal.
Jul 14 '15 #10
NeoPa
32,556 Expert Mod 16PB
iPanterra:
I hope this was what you were after.
Yes :-)
Jul 14 '15 #11
Zmbd

I tried your code, however im getting a compile error at the &amp; section
Jul 15 '15 #12
zmbd
5,501 Expert Mod 4TB
Open the Macro editor and enter the string as given in the grey box below the codeblock in Post#6

You should be able to toggle the numbers off in Post#6 around the code block, select, copy...

Few things to note...
Open notepad, cut and paste the code there first.
Delete any leading blank lines
Change:
<UserInterfaceMacro For="Command10" Event="OnClick">
So that "Command10" is the name of your command-button
<UserInterfaceMacro For="MeSaHaveSaNewNameBetchaBetcha" Event="OnClick">

Open the command button on your form, on click event, macro builder, paste the altered code in to the window.

You should now see the correctly formatted string, etc...
Jul 16 '15 #13
I approached this from a different angle with some help, and I have managed to get this to work, saving a form to a location with file name changes depending on variables in the form. End result is

16_07_15_Foundry_Furnace_Test 101, in PDF format.

This is perfect and I appreciate all the help I have received thus far.
Jul 16 '15 #14

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

Similar topics

0
by: pepin_labulle | last post by:
I'm a newbie with XQuery and I'm trying to execute a query with Saxon. If I don't specify the XML source file name in the query, Saxon raises the following error :...
1
by: Corobori | last post by:
I have got an XP machine where I have installed a SQL Server for my testing. I recently started working on a vb.net project requiring MSDE. After executing the Setup, made using Install Shield,...
1
by: Daniel | last post by:
If my System.IO.StreamWriter Write method throws "The specified network name is no longer available." and I try to Dispose or Close it in the finaly clause the close or dispose method just throws...
10
by: Ben Finney | last post by:
Howdy all, Question: I have Python modules named without '.py' as the extension, and I'd like to be able to import them. How can I do that? Background: On Unix, I write programs intended to...
22
by: Dale Pennington | last post by:
I find myself in the odd situation of trying to determine the name of a file that has been opened somewhere else with an fopen call, so all I have is the FILE * from that fopen call. I perused my...
1
by: weird0 | last post by:
System.Data.SqlClient.SqlException: An attempt to attach an auto- named database for file "Location" failed. A database with the same name exists, or specified file cannot be opened, or it is...
185
by: jacob navia | last post by:
Hi We are rewriting the libc for the 64 bit version of lcc-win and we have added a new field in the FILE structure: char *FileName; fopen() will save the file name and an accessor function will...
5
by: sandhya20 | last post by:
Hi, the following code is working fine when i am running the application.exe file. System.Diagnostics.Process.Start(filename); But when i am opening it by using "Run As" option & giving user...
1
by: Jesus Reynoso | last post by:
Good afternoon i have a problem with my database. i was install my software in my Pc but when i want to enter in the program an error appear. run-time error '75' the specified path/file...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.