Extra record at x-out

C

Cheswyck

I'm initalizing the 'date' in my current record to today
or to the previous record's date. However, when I x-out of
the form the current record, the one with only the date in
it, is written to the table. This would be ok if the user
x-out while still on the last filled record. Where/How do
I check. I think it would be in the before-update
property but how do I say 'dont write'?
 
G

Gerald Stanley

In the form's BeforeUpdate eventhandler, you can set Cancel
= True to prevent an update.

Hope This Helps
Gerald Stanley MCSD
 
G

Guest

I don't think I have it right. I entered the following
code in the FORMS 'before update' event:
If (timTime = 0) And (timJobID = " ") Then
MsgBox "Record not modified."
Set Cancel = True
End If
timTime and timJobID are the record's data names and the
values in the table for the extra records. I put in
the 'msgbox' to see if the test was true but the set
command didn't work but I'm not getting the display either.
In 'help' it references .CancelUpdate but it didn't work
for me nor did 'cancel = true' wihout the 'set'. So as
you can see, I'm lost here. I think I need a more
detailed description or the exact code. I'm using Access
2000 under Windows ME.

Thanks for your help
 
G

Gerald Stanley

Without seeing your form design, it is hard to be accurate
but try
If Len(timTime) = 0 Or Len(timJobId) = 0 then
MsgBox "Record not modified."
Cancel = True
End If

I am assuming that timTime and timJobId are controls on
your form and by checking the length to be zero means that
one or both have no data entered.

Hope This Helps
Gerald Stanley MCSD
 
G

guest

You can also use the forms NewRecord property. In the forms OnClose event you could put something like
If Me.NewRecord And Not Isnull(Me.<Primary Key Field Name>) The
Docmd.Runcmd acCmdDeleteRecor
(or this: Docmd.SetWarnings Fals
Docmd.RunSQL "DELETE FROM <table> WHERE <Primary Key>=" & Me.<Primary Key
Docmd.SetWarnings True
End I
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top