X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Add Date To Field Based On Another Field, Access 2013    
post Jun 22 2019, 01:34 PM

Posts: 21
Joined: 11-March 14

I have two fields ChangesApproved which is Yes/No and ApprovalDate which is a date.

When I click on ChangesApproved and go from No to Yes, I'd like ApprovalDate to show the date and time that I checked the box. But if I go from Yes to No, I'd like ApprovalDate to go back to null.

How can I do that?

Go to the top of the page
post Jun 22 2019, 01:57 PM

Access Wiki and Forums Moderator
Posts: 75,710
Joined: 19-June 07
From: SunnySandyEggo

On the form, in the AfterUpdate event of ChangesApproved, try:
If Me.ChangesApproved=True Then
    Me.ApprovalDate = Now()
    Me.ApprovalDate = Null
End If

Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
post Jun 22 2019, 02:07 PM

UtterAccess VIP
Posts: 9,723
Joined: 25-October 10
From: Gulf South USA

Hi: I'm a bit behind theDBguy posting this, but my solution was similar ...

Private Sub ChangesApproved_AfterUpdate()
If Me!ChangesApproved Then Me!ApprovalDate = Now()
If Not Me!ChangesApproved Then Me!ApprovalDate = Null
End Sub

Also, see the demo attached ...

Attached File(s)
Attached File  ChangeApprovedDate.zip ( 21.41K )Number of downloads: 0

"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
post Jun 22 2019, 02:32 PM

UA Admin
Posts: 35,304
Joined: 20-June 02
From: Newcastle, WA

I took another path. Don't bother with a checkbox that does exactly the same thing as the date field. Plus, because it is redundant, you have to fret over this synchronization problem.

I'd drop that ChangesApproved Yes/No field. Having a date in the ApprovalDate field is exactly the same as saying "approved". The absence of a date in that field is exactly the same as saying "Nope, not approved".

My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    17th July 2019 - 03:31 AM