ExportingWithFormating with Variable file path and name (1 Viewer)

NeedHelpASAP

New member
Local time
Today, 08:20
Joined
Jul 25, 2019
Messages
7
Im wondering if it is possible to use the ExportWithFormating macro with an Output File dependent on a combo box and date picker located on separate forms. the expression I have right now isnt working

=P:...\Merch Database" & [Forms]![frmReports]![Combo256] & "\Copy of EmpRouteMatrix" & [Forms]![frmReports]![Combo256] & ".pdf"

(didnt include the entire file name as its pretty long but the first combo is the variable folder name and the second is connected to a date picker)

Is this possible in a macro or am I in over my head?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:20
Joined
Oct 29, 2018
Messages
21,447
Hi. Welcome to the forum! Yes, this should be possible provided you didn't make any spelling errors and the forms are currently open when you run the macro.
 

NeedHelpASAP

New member
Local time
Today, 08:20
Joined
Jul 25, 2019
Messages
7
I double checked the spelling and it all looks good, I did notice I had the same combo box in the expression twice, here is the updated

="P:...\Merch Database\" & [Forms]![frmReports]![Combo256] & "\Copy of EmpRouteMatrix" & [Forms]![USER PAGE]![Text67] & ".pdf"

I am still getting an error saying it cant save the output data, any thought to what might have been wrong?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:20
Joined
Oct 29, 2018
Messages
21,447
I double checked the spelling and it all looks good, I did notice I had the same combo box in the expression twice, here is the updated

="P:...\Merch Database" & [Forms]![frmReports]![Combo256] & "\Copy of EmpRouteMatrix" & [Forms]![USER PAGE]![Text67] & ".pdf"

I am still getting an error saying it cant save the output data, any thought to what might have been wrong?
Add a Message Box action to verify the file name is correct and valid (no illegal characters).
 
Last edited:

NeedHelpASAP

New member
Local time
Today, 08:20
Joined
Jul 25, 2019
Messages
7
The message box appears with the correct file location and name but I am still getting the output error. This would create a new file, would that cause the error?
 

GinaWhipp

AWF VIP
Local time
Today, 11:20
Joined
Jun 21, 2011
Messages
5,900
What is the error message you are getting? Oh, an include the number if there is one.
 

NeedHelpASAP

New member
Local time
Today, 08:20
Joined
Jul 25, 2019
Messages
7
the error says:

"Microsoft Access can't save the output data to the file you've selected"

no error number or anything like that. :banghead:
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:20
Joined
Oct 29, 2018
Messages
21,447
the error says:

"Microsoft Access can't save the output data to the file you've selected"

no error number or anything like that. :banghead:
Hi. Can you post the macro code? Thanks.
 

NeedHelpASAP

New member
Local time
Today, 08:20
Joined
Jul 25, 2019
Messages
7

Attachments

  • Capture.PNG
    Capture.PNG
    11.1 KB · Views: 114

GinaWhipp

AWF VIP
Local time
Today, 11:20
Joined
Jun 21, 2011
Messages
5,900
Hmm, in addition to the code are you sure you have the correct permissions to said folder?
 

Gasman

Enthusiastic Amateur
Local time
Today, 16:20
Joined
Sep 21, 2011
Messages
14,217
Can you show us the MSGBOX output please?
 

NeedHelpASAP

New member
Local time
Today, 08:20
Joined
Jul 25, 2019
Messages
7
So I was messing around with it and realized that the date in the filename is coming up as "mm/dd/yyyy" and the / are the problem. Any way to change it to a - or a .??
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:20
Joined
Oct 29, 2018
Messages
21,447
So I was messing around with it and realized that the date in the filename is coming up as "mm/dd/yyyy" and the / are the problem. Any way to change it to a - or a .??
Hi. Yes, try using the Format() function.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:20
Joined
May 7, 2009
Messages
19,227
also if you include a textbox/combobox with date and has "/" as delimiter in them, it won't save. try formatting it using "." or "-" or "_" as delimeter:
Code:
& Format(yourControl, "dd_mm_yyyy")

also you might want to check if the pdf already exists, therefore delete it first
Code:
if dir("thePathAndFileName.pdf") <> "" Then Kill ("ThePathAndFileName.pdf")
 

Users who are viewing this thread

Top Bottom