MS-Access button is using fileModDate = f.DateLastModified;how do I compare the fileModDate to todays date
In this database there are buttons for each day of the week; user is required to click the button relating to the current day of the week and this executes some basic functions. I need to add in a contingency which makes the code look at the last modified date of the files that the button will look at and compare it to today's date. If the last modified date isn't today's date then I don't want the user to be able to execute the commands behind that button, and be forced to execute the correct button, which does actually relate to the current day of the week.
Private Sub Command19_Click()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Dim FileExt As String
Dim fileModDate As String
Dim Response2 As Integer
'To have a second message box, do I need to set another parameter here? I.E Dim Response3 As Integer (?)
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("\file_pathfile_name.csv")
fileModDate = f.DateLastModified
Response2 = MsgBox(prompt:="Files are dated - " & fileModDate & ". Do you wish to Continue?", Buttons:=vbYesNo)
If Response2 = vbNo Then
Exit Sub
Else
'I assume I need to compare fileModDate to current date here. IF this is today's date then continue, IF NOT, then prompt user with message, "Button date does not match today's date". Do not allow user to continue until they have clicked a button for which the fileModDate = today's date.
End If
FromPath = "\file_path"
ToPath = "\file_path"
MsgBox "Files Copied"
End Sub
I'm aware that this code won't look right in the post but as this is my first time posting here, I would appreciate if someone could point out my error. Also, I have searched the site for answers to this question and have not found an answer relating to this specific example.
vba ms-access
add a comment |
In this database there are buttons for each day of the week; user is required to click the button relating to the current day of the week and this executes some basic functions. I need to add in a contingency which makes the code look at the last modified date of the files that the button will look at and compare it to today's date. If the last modified date isn't today's date then I don't want the user to be able to execute the commands behind that button, and be forced to execute the correct button, which does actually relate to the current day of the week.
Private Sub Command19_Click()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Dim FileExt As String
Dim fileModDate As String
Dim Response2 As Integer
'To have a second message box, do I need to set another parameter here? I.E Dim Response3 As Integer (?)
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("\file_pathfile_name.csv")
fileModDate = f.DateLastModified
Response2 = MsgBox(prompt:="Files are dated - " & fileModDate & ". Do you wish to Continue?", Buttons:=vbYesNo)
If Response2 = vbNo Then
Exit Sub
Else
'I assume I need to compare fileModDate to current date here. IF this is today's date then continue, IF NOT, then prompt user with message, "Button date does not match today's date". Do not allow user to continue until they have clicked a button for which the fileModDate = today's date.
End If
FromPath = "\file_path"
ToPath = "\file_path"
MsgBox "Files Copied"
End Sub
I'm aware that this code won't look right in the post but as this is my first time posting here, I would appreciate if someone could point out my error. Also, I have searched the site for answers to this question and have not found an answer relating to this specific example.
vba ms-access
add a comment |
In this database there are buttons for each day of the week; user is required to click the button relating to the current day of the week and this executes some basic functions. I need to add in a contingency which makes the code look at the last modified date of the files that the button will look at and compare it to today's date. If the last modified date isn't today's date then I don't want the user to be able to execute the commands behind that button, and be forced to execute the correct button, which does actually relate to the current day of the week.
Private Sub Command19_Click()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Dim FileExt As String
Dim fileModDate As String
Dim Response2 As Integer
'To have a second message box, do I need to set another parameter here? I.E Dim Response3 As Integer (?)
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("\file_pathfile_name.csv")
fileModDate = f.DateLastModified
Response2 = MsgBox(prompt:="Files are dated - " & fileModDate & ". Do you wish to Continue?", Buttons:=vbYesNo)
If Response2 = vbNo Then
Exit Sub
Else
'I assume I need to compare fileModDate to current date here. IF this is today's date then continue, IF NOT, then prompt user with message, "Button date does not match today's date". Do not allow user to continue until they have clicked a button for which the fileModDate = today's date.
End If
FromPath = "\file_path"
ToPath = "\file_path"
MsgBox "Files Copied"
End Sub
I'm aware that this code won't look right in the post but as this is my first time posting here, I would appreciate if someone could point out my error. Also, I have searched the site for answers to this question and have not found an answer relating to this specific example.
vba ms-access
In this database there are buttons for each day of the week; user is required to click the button relating to the current day of the week and this executes some basic functions. I need to add in a contingency which makes the code look at the last modified date of the files that the button will look at and compare it to today's date. If the last modified date isn't today's date then I don't want the user to be able to execute the commands behind that button, and be forced to execute the correct button, which does actually relate to the current day of the week.
Private Sub Command19_Click()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Dim FileExt As String
Dim fileModDate As String
Dim Response2 As Integer
'To have a second message box, do I need to set another parameter here? I.E Dim Response3 As Integer (?)
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("\file_pathfile_name.csv")
fileModDate = f.DateLastModified
Response2 = MsgBox(prompt:="Files are dated - " & fileModDate & ". Do you wish to Continue?", Buttons:=vbYesNo)
If Response2 = vbNo Then
Exit Sub
Else
'I assume I need to compare fileModDate to current date here. IF this is today's date then continue, IF NOT, then prompt user with message, "Button date does not match today's date". Do not allow user to continue until they have clicked a button for which the fileModDate = today's date.
End If
FromPath = "\file_path"
ToPath = "\file_path"
MsgBox "Files Copied"
End Sub
I'm aware that this code won't look right in the post but as this is my first time posting here, I would appreciate if someone could point out my error. Also, I have searched the site for answers to this question and have not found an answer relating to this specific example.
vba ms-access
vba ms-access
edited Jan 2 at 12:18


Santosh
10.7k23160
10.7k23160
asked Jan 2 at 12:07
VanhinsberghVanhinsbergh
32
32
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Is this what you want ?
If Format(F.DateLastModified, "dd/mm/yyyy") <> Format(Now, "dd/mm/yyyy") Then
MsgBox ("Button date does not match today's date")
Exit Sub
End If
Hi Thomas G, Where would this piece of code be placed? In my sample code above, you can see where I assumed it would go; I've entered the following note - 'I assume I need to compare fileModDate to current date here. IF this is today's date then continue, IF NOT, then prompt user with message, "Button date does not match today's date". Do not allow user to continue until they have clicked a button for which the fileModDate = today's date. I've tested this, and nothing happens; I might be wrong in thinking this is where the piece of code needs to be inserted though.
– Vanhinsbergh
Jan 6 at 10:57
Thomas G, I figured out where to put the code and it works a treat, thank you for your help! :)
– Vanhinsbergh
Jan 6 at 15:41
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006080%2fms-access-button-is-using-filemoddate-f-datelastmodifiedhow-do-i-compare-the%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this what you want ?
If Format(F.DateLastModified, "dd/mm/yyyy") <> Format(Now, "dd/mm/yyyy") Then
MsgBox ("Button date does not match today's date")
Exit Sub
End If
Hi Thomas G, Where would this piece of code be placed? In my sample code above, you can see where I assumed it would go; I've entered the following note - 'I assume I need to compare fileModDate to current date here. IF this is today's date then continue, IF NOT, then prompt user with message, "Button date does not match today's date". Do not allow user to continue until they have clicked a button for which the fileModDate = today's date. I've tested this, and nothing happens; I might be wrong in thinking this is where the piece of code needs to be inserted though.
– Vanhinsbergh
Jan 6 at 10:57
Thomas G, I figured out where to put the code and it works a treat, thank you for your help! :)
– Vanhinsbergh
Jan 6 at 15:41
add a comment |
Is this what you want ?
If Format(F.DateLastModified, "dd/mm/yyyy") <> Format(Now, "dd/mm/yyyy") Then
MsgBox ("Button date does not match today's date")
Exit Sub
End If
Hi Thomas G, Where would this piece of code be placed? In my sample code above, you can see where I assumed it would go; I've entered the following note - 'I assume I need to compare fileModDate to current date here. IF this is today's date then continue, IF NOT, then prompt user with message, "Button date does not match today's date". Do not allow user to continue until they have clicked a button for which the fileModDate = today's date. I've tested this, and nothing happens; I might be wrong in thinking this is where the piece of code needs to be inserted though.
– Vanhinsbergh
Jan 6 at 10:57
Thomas G, I figured out where to put the code and it works a treat, thank you for your help! :)
– Vanhinsbergh
Jan 6 at 15:41
add a comment |
Is this what you want ?
If Format(F.DateLastModified, "dd/mm/yyyy") <> Format(Now, "dd/mm/yyyy") Then
MsgBox ("Button date does not match today's date")
Exit Sub
End If
Is this what you want ?
If Format(F.DateLastModified, "dd/mm/yyyy") <> Format(Now, "dd/mm/yyyy") Then
MsgBox ("Button date does not match today's date")
Exit Sub
End If
answered Jan 2 at 15:08


Thomas GThomas G
7,46872033
7,46872033
Hi Thomas G, Where would this piece of code be placed? In my sample code above, you can see where I assumed it would go; I've entered the following note - 'I assume I need to compare fileModDate to current date here. IF this is today's date then continue, IF NOT, then prompt user with message, "Button date does not match today's date". Do not allow user to continue until they have clicked a button for which the fileModDate = today's date. I've tested this, and nothing happens; I might be wrong in thinking this is where the piece of code needs to be inserted though.
– Vanhinsbergh
Jan 6 at 10:57
Thomas G, I figured out where to put the code and it works a treat, thank you for your help! :)
– Vanhinsbergh
Jan 6 at 15:41
add a comment |
Hi Thomas G, Where would this piece of code be placed? In my sample code above, you can see where I assumed it would go; I've entered the following note - 'I assume I need to compare fileModDate to current date here. IF this is today's date then continue, IF NOT, then prompt user with message, "Button date does not match today's date". Do not allow user to continue until they have clicked a button for which the fileModDate = today's date. I've tested this, and nothing happens; I might be wrong in thinking this is where the piece of code needs to be inserted though.
– Vanhinsbergh
Jan 6 at 10:57
Thomas G, I figured out where to put the code and it works a treat, thank you for your help! :)
– Vanhinsbergh
Jan 6 at 15:41
Hi Thomas G, Where would this piece of code be placed? In my sample code above, you can see where I assumed it would go; I've entered the following note - 'I assume I need to compare fileModDate to current date here. IF this is today's date then continue, IF NOT, then prompt user with message, "Button date does not match today's date". Do not allow user to continue until they have clicked a button for which the fileModDate = today's date. I've tested this, and nothing happens; I might be wrong in thinking this is where the piece of code needs to be inserted though.
– Vanhinsbergh
Jan 6 at 10:57
Hi Thomas G, Where would this piece of code be placed? In my sample code above, you can see where I assumed it would go; I've entered the following note - 'I assume I need to compare fileModDate to current date here. IF this is today's date then continue, IF NOT, then prompt user with message, "Button date does not match today's date". Do not allow user to continue until they have clicked a button for which the fileModDate = today's date. I've tested this, and nothing happens; I might be wrong in thinking this is where the piece of code needs to be inserted though.
– Vanhinsbergh
Jan 6 at 10:57
Thomas G, I figured out where to put the code and it works a treat, thank you for your help! :)
– Vanhinsbergh
Jan 6 at 15:41
Thomas G, I figured out where to put the code and it works a treat, thank you for your help! :)
– Vanhinsbergh
Jan 6 at 15:41
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006080%2fms-access-button-is-using-filemoddate-f-datelastmodifiedhow-do-i-compare-the%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown