Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 142
  • Last Modified:

Trying to export fiel to desktop with date field included in the name of the file

I have this code which exports a file to the desktop just fine...

strXLFile = strDesktopPath & "\Checklist - " & Forms!frmIHMGnotes.Text328 & " To Office " & ".xml"

But when I try to add a field from the open form (txtDateOfVisit), I get an error using...

strXLFile = strDesktopPath & "\Checklist - " & Forms!frmIHMGnotes.Text328 & " To Office " & Me.txtDateofVisit & ".xml"

I'm pretty sure it's a syntax thing.  Can someone help?

--Steve
0
SteveL13
Asked:
SteveL13
  • 2
2 Solutions
 
mankowitzCommented:
does it work with bang syntax?

Try

strXLFile = strDesktopPath & "\Checklist - " & Forms!frmIHMGnotes.Text328 & " To Office " & Me!txtDateofVisit & ".xml"
0
 
SteveL13Author Commented:
That did not work but I think I know why but don't know how to fix it.   txtDateofVisit  is a date field like 11/14/2014.  But the exported file name can't have "/" marks in it.  Right?

So then how can I convert 11/14/2014 to read 11142014 (without the slash marks)?

--Steve
0
 
PatHartmanCommented:
& Format(Me.txtDateofVisit, "yyyymmdd") &

or use dashes

& Format(Me.txtDateofVisit, "mm-dd-yyyy") &
0
 
SteveL13Author Commented:
Thanks to both of you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now