Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delay saving a record until the last date entered

Status
Not open for further replies.

Conner

Technical User
Nov 29, 2000
44
0
0
US
I continue to have problems with "not saving a record" until all data fields are complete....

I have reduced my database to as simple as it can be:

tblPINcode tblDateTime
PinCode (Prim.Key) DateId
LastName PinCode (for.Key)
FirstName Today (Date Function)
TimeIn (Time Function)
TimeOut (Time Function)


There is a mainform(PinCode,LastName,FirstName) and a subform(Today,TimeIn,TimeOut). The fields in the subform are populated with the following code:


Private sub form_Load()
Me.Today=Date

If IsNull(Me.TimeIn)Then
Me.TimeIn=Time
ElseIf IsNull(Me.TimeOut) Then
Me.TimeOut=Time
End If

End Sub


My problem is I can't get the record to "save" at the right time. I've used the data entry property set to "yes". This caused the Date and TimeIn to be "saved" in the table on a row different from TimeOut. (I couldn't figure out how to get to the next step:ElapsedTime:[TimeOut]-[TimeIn].

I tried using an update event with DoCmd.RunCommand acCmdSaveRecord, but this didn't work.

How can I make my database "wait" until "TimeOut" is entered to save the three pieces of data (Today,TimeIn,TimeOut)on the same row in the table, and, at the same time, insure that the next day's record will not replace the one I'm trying to save...







 
In the subform's module put a Form_BeforeUpdate() event


Private Sub Form_BeforeUpdate(Cancel as integer)
If nz(me.TimeOut) = "" then
'You can test for whatever you want here.
'I'm testing whether there is any input at all in TimeOut
'But you can test it to make sure it is a valid time etc

cancel = true
'This line will cancel the update
end if
End Sub

Alec Doughty
Doughty Consulting P/L

"Life's a competition. Play hard, but play fair"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top