I'm looking for my form to separate date components by a period or a dash, rather than a slash. For instance, 26-5-2021 or 26.5.2021 rather than 26/5/2021
Any idea?
I'm looking for my form to separate date components by a period or a dash, rather than a slash. For instance, 26-5-2021 or 26.5.2021 rather than 26/5/2021
Any idea?
did you try: format([dateFld],"dd-mm-yyyy")
Probably several ways to accomplish, depending on whether or not you intend to just view, modify the value or store it in a table field. IMO that has to be revealed because f'rinstance, no point in giving you an expression for a calculated field that needs to be bound because you can't bind them to table fields.
EDIT - Perhaps I focused too much on the record itself. Format function will show as you wish but won't store it that way. However, it will also change the value to a string so beware of that. It is also possible that the last Monday in a year can be reported as the wrong week should week calculations come in to play.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
To ranman: In a query or the form itself? I'm not sure where to put that in the form properties
To micron: So the reason I'm looking to remove the slashes is that I have a VBA that exports the entry to a pdf and I want to use the date as a component in the file name. However, windows doesn't allow slashes in file names (periods or dashes are fine tho). So I think I just need to modify the value in the form itself but I could be wrong and hence why I'm here lol
Just format the date with the dashes in your export routine.
No need to mess with the format in the form at all.
Code:Dim sFilename as String sFilename = "MyExport_" & format (Me.txtYourDateFieldControl, "yyyy-mm-dd") & ".pdf"
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
I see. I often use dates for file versions but just use numbers: 05262021 is today (US date format).
If you have code that's building a file path string, use Replace function on it and replace / with - or . Then output as a file.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
That worked Minty! Thank you! You guys are seriously the best
I use that specific format (YYYYMMDD) almost all the time, as the files created with the same starting name will then sort by date correctly, if you sort the folder contents by name.
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
I'm lazy so I like mine better
sFilename = "MyExport_" & format (Me.txtYourDateFieldControl, "yyyy-mm-dd") & ".pdf"
sFilename = "MyExport_" & Replace(Me.txtYourDateFieldControl, "/","-") & ".pdf"
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓