Access General Date Forced To Have Date And Time

Joined
Aug 2, 2017
Messages
2
Reaction score
1
Hi all!
Before I ask my question I just want to let everyone know that this site has been a great help.

So, I have a TextBox that needs to accept a date and time. Simple enough. However, the data that I need to collect has to always have a date and time but when I use General Date it will accept either Date or Time or both as its designed to do so.

I have tried setting

Format as " m/d/yyyy h:nn:ss ampm "
Input Mask as " 90/90/0000\ 99:00:00\ >LL;0;_ "

and tinkered with me.textbox.format() as an if statment

But this leads to the other issue that most of this data will be pasted into the form in either of the below formats.

7/19/2017 12:08:14 PM
Wednesday, July 19, 2017 12:08:14 PM

I'm stumped and haven't been able to figure this out through research or my own luck.

Any help is appreciated and thank you all.
 
So.... I think I figured it out. Been testing it and it seems to result in the way i need it to. So I have the Form/Table set to Date/Time Field formatted as a General Date. This will at least validate that the information inputted in the text-box is a date/time of some sort. Then I added the below code to make it follow a validation rule of sort. So far it seems regardless of the way information is pasted in the end result is always MM/DD/YYYY HH:MM:SS AMPM


If Me.YourTextBox Like "**/**/**** **:**:** **" Then
Cancel = False
Else
MsgBox ("Please enter a date and time in this format MM/DD/YYYY HH:MM:SS AM/PM")
Cancel = True
End If


I'm still open to suggestions if there is a more efficient way of doing this. If not I hope this information will be found helpful to others.


Thanks All,
 
Thanks for posting the solution @ButterStick - it's a big help when people report back when they find an answer like this :).
 
Back
Top