VBA code for date criteria IfPrivate Sub completed_AfterUpdate()

When I try the BeforeUpdate code it creates the illustrated error when I go to close the form. If I dont click the checkbox then I can close the form.


Private Sub completed_BeforeUpdate(Cancel As Integer)
If Date < Me.all_date Then
Cancel = True
Else
Me.comp_date = Date
End If
End Sub

Is there any alternative action that can be used instead of cancel ?
 
I can't see how that's related to that code. There must be something else causing the disturbance. Upload a cut-down version of your db (with only the relevant parts and non-confidential test data) and I'll take a look and advice.
 
The form is Completed
 

Attachments

Thank you so much for your time and patience. I hope others benefit also from your courtesy....and knowledge.
 
Guys. Just to report that it didn't work. It is (as suspected) a problem with it being an continuous form.

For anybody else I managed to get round the issue by using the set focus to [comp_date] after update on [completed] then opening a warning message on Gotfocus of [comp_date]
On close of the warning message I run an UpdateQuery to change the [completed] to False and [comp_date] to Null then refresh the form.
 
I don't understand that last comment?

Why do I not upload a database that does not work?
 
You stated
Guys. Just to report that it didn't work.
... meaning the db the suggestions in the db that I uploaded earlier didn't work. So I'm asking that you upload a db with the suggested changes that doesn't work.
 
Oh I see. I just used what you had sent to me.
 
Did you use that particular db or you copied and pasted the code? If it's the latter, upload that db and I'll take a look.
 
I used your version but when there are two processes and you click a process where the date is prior to the date allocated it works fine (ie you cant add a date) but when you then try to complete a date that does meet the criteria is seems as though its locked.
 
If you upload the db with the type of data you just explained and tell me steps to reproduce the problem, I'll take a look. Workarounds should be a last resort.
 

Users who are viewing this thread

Back
Top Bottom