A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Procedure to check date/time



 
 
Thread Tools Display Modes
  #1  
Old January 9th, 2009, 04:03 AM posted to microsoft.public.access.gettingstarted
jesseu via AccessMonster.com
external usenet poster
 
Posts: 3
Default Procedure to check date/time

Hi all, New to code
I have a form with date txtbox operator needs to place both date and time of
job completion.
some just place dates and some place just the time. Need to write code on
before-update.
1. to check that both date and time is place
2. give message if either one is missing
3. not allowing next entry until both are given.

Thank You Team
Jesse

--
Message posted via http://www.accessmonster.com

  #2  
Old January 9th, 2009, 05:24 AM posted to microsoft.public.access.gettingstarted
tina
external usenet poster
 
Posts: 1,997
Default Procedure to check date/time

if there is only one field to hold both the date and time, have you
considered using an input mask to control the data entry? something along
the lines of

99/99/00\ 99:00\ LL;0;_

suggest you read up on the Input Mask property so you'll understand how it
works.

hth


"jesseu via AccessMonster.com" u39476@uwe wrote in message
news:8fe89769c4fcd@uwe...
Hi all, New to code
I have a form with date txtbox operator needs to place both date and time

of
job completion.
some just place dates and some place just the time. Need to write code on
before-update.
1. to check that both date and time is place
2. give message if either one is missing
3. not allowing next entry until both are given.

Thank You Team
Jesse

--
Message posted via http://www.accessmonster.com



  #3  
Old January 9th, 2009, 05:58 AM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Procedure to check date/time

On Fri, 09 Jan 2009 04:03:46 GMT, "jesseu via AccessMonster.com" u39476@uwe
wrote:

Hi all, New to code
I have a form with date txtbox operator needs to place both date and time of
job completion.
some just place dates and some place just the time. Need to write code on
before-update.
1. to check that both date and time is place
2. give message if either one is missing
3. not allowing next entry until both are given.

Thank You Team
Jesse


The user can be trained to type Ctrl-; to automatically enter the current
system date and time; or you can put code in the textbox's doubleclick event:

Private Sub txtTimeComplete_DblClick()
Me!txtTimeComplete = Now
End Sub

to do the same.

If the user will be entering data at some time after the job completion, you
could use this code in the control's BeforeUpdate:

Private Sub txtTimeComplete_BeforeUpdate(Cancel as Integer)
If Not IsDate(Me!txtTimeComplete) Then
Cancel = True
MsgBox "Please enter the date and time of job completion", vbOKOnly
Elseif TimeValue(Me!txtTimeComplete) = 0 Then
Cancel = True
Msgbox "Please enter the time as well as the date", vbOKOnly
Elseif DateValue(Me!txtTimeComplete) = 0 Then
Cancel = True
Msgbox "Please enter the date as well as the time", vbOKOnly
End If
End Sub

Note that this will prevent the user from entering a completion if they
actually completed the job exactly at midnight, since that's the 0 of time.
--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:06 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.