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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|