Conditional date on original Change

V

Very Basic User

Hello,
I have two fields in my form that I want to interact "Status" and "Date
Completed" the code below gets me close, but does not look for the second
condition that I need it to. What I need in words is... (If Status =
completed and date completed is blank, then change date completed to now. If
both of these conditions are not met, leave the date completed alone. I need
the second condition so that if a user puts the status back to "in progress"
and then changes it back to completed, I don't want the original completed
date to change.

Thanks in advance for your help!

Private Sub Status_AfterUdate()
If Me![Status]=â€Completed†Then
Me![Actual completion date]=Now()
End if
End Sub
 
B

Beetle

Private Sub Status_AfterUdate()
If Me![Status]=â€Completed†And IsNull(Me![Actual Completion Date]) Then
Me![Actual completion date]=Now()
End if
End Sub
 
P

Piet Linden

Hello,
I have two fields in my form that I want to interact "Status" and "Date
Completed" the code below gets me close, but does not look for the second
condition that I need it to. What I need in words is... (If Status =
completed and date completed is blank, then change date completed to now.If
both of these conditions are not met, leave the date completed alone. I need
the second condition so that if a user puts the status back to "in progress"
and then changes it back to completed, I don't want the original completed
date to change.

Thanks in advance for your help!

Private Sub Status_AfterUdate()
If Me![Status]=”Completed” AND Me![Actual Completion Date] IS NULL Then
Me![Actual completion date]=Now()
End if
End Sub

If Me![Status]=”Completed” AND Me![Actual Completion Date] IS NULL Then
 
V

Very Basic User

I tried this code, but it didn't work. Is this saying if [Status] is both
Completed and Null then add todays date? What I need is... If [Status] is
Completed and [Actual Completed Date] is null, then make actual completed
date = Now()
--
Thank you for your time!
John


Beetle said:
Private Sub Status_AfterUdate()
If Me![Status]=â€Completed†And IsNull(Me![Actual Completion Date]) Then
Me![Actual completion date]=Now()
End if
End Sub

--
_________

Sean Bailey


Very Basic User said:
Hello,
I have two fields in my form that I want to interact "Status" and "Date
Completed" the code below gets me close, but does not look for the second
condition that I need it to. What I need in words is... (If Status =
completed and date completed is blank, then change date completed to now. If
both of these conditions are not met, leave the date completed alone. I need
the second condition so that if a user puts the status back to "in progress"
and then changes it back to completed, I don't want the original completed
date to change.

Thanks in advance for your help!

Private Sub Status_AfterUdate()
If Me![Status]=â€Completed†Then
Me![Actual completion date]=Now()
End if
End Sub
 
B

Beetle

What I need is... If [Status] is Completed and
[Actual Completed Date] is null, then make actual
completed date = Now()

That's what the code does. I've tested it on my end and it works
as posted.

Are all of your field/control names correct in the code?

Is [Status] a combo box, and if so is "Completed" in the
bound column?

Is [Actual Completed Date] a Date/Time field?
(I was assuming it was but maybe not)

--
_________

Sean Bailey


Very Basic User said:
I tried this code, but it didn't work. Is this saying if [Status] is both
Completed and Null then add todays date? What I need is... If [Status] is
Completed and [Actual Completed Date] is null, then make actual completed
date = Now()
--
Thank you for your time!
John


Beetle said:
Private Sub Status_AfterUdate()
If Me![Status]=â€Completed†And IsNull(Me![Actual Completion Date]) Then
Me![Actual completion date]=Now()
End if
End Sub

--
_________

Sean Bailey


Very Basic User said:
Hello,
I have two fields in my form that I want to interact "Status" and "Date
Completed" the code below gets me close, but does not look for the second
condition that I need it to. What I need in words is... (If Status =
completed and date completed is blank, then change date completed to now. If
both of these conditions are not met, leave the date completed alone. I need
the second condition so that if a user puts the status back to "in progress"
and then changes it back to completed, I don't want the original completed
date to change.

Thanks in advance for your help!

Private Sub Status_AfterUdate()
If Me![Status]=â€Completed†Then
Me![Actual completion date]=Now()
End if
End Sub
 
V

Very Basic User

Hello Sean,

I've double checked my names field/control names and they all look good. Teh
[Status] is a combo box using a list versus a table or query to pull from it
contains "In Progress, Completed, or Canceled" and the date is a Date/Time
field. When I change from my original code of... just to get a date it works,
but When I changed to yours, I didn't even get a date when changing status to
completed. My code gives me a date but the date time stamp changes every time
I switch from completed to In progress and then back to compelted.

Private Sub Statu_AfterUdate()
If Me![Status]=â€Completed†Then
Me![Actual completion date]=Now()
End if
End Sub


I appreciate your help on this.
--
Thank you for your time!
John


Beetle said:
What I need is... If [Status] is Completed and
[Actual Completed Date] is null, then make actual
completed date = Now()

That's what the code does. I've tested it on my end and it works
as posted.

Are all of your field/control names correct in the code?

Is [Status] a combo box, and if so is "Completed" in the
bound column?

Is [Actual Completed Date] a Date/Time field?
(I was assuming it was but maybe not)

--
_________

Sean Bailey


Very Basic User said:
I tried this code, but it didn't work. Is this saying if [Status] is both
Completed and Null then add todays date? What I need is... If [Status] is
Completed and [Actual Completed Date] is null, then make actual completed
date = Now()
--
Thank you for your time!
John


Beetle said:
Private Sub Status_AfterUdate()
If Me![Status]=â€Completed†And IsNull(Me![Actual Completion Date]) Then
Me![Actual completion date]=Now()
End if
End Sub

--
_________

Sean Bailey


:

Hello,
I have two fields in my form that I want to interact "Status" and "Date
Completed" the code below gets me close, but does not look for the second
condition that I need it to. What I need in words is... (If Status =
completed and date completed is blank, then change date completed to now. If
both of these conditions are not met, leave the date completed alone. I need
the second condition so that if a user puts the status back to "in progress"
and then changes it back to completed, I don't want the original completed
date to change.

Thanks in advance for your help!

Private Sub Status_AfterUdate()
If Me![Status]=â€Completed†Then
Me![Actual completion date]=Now()
End if
End Sub
 
B

Beetle

Hmmm...

So if you start a new record and select "Complete" in the combo
box, no value gets inserted into the [Actual completion date] field?

Can you post the new code exactly as you have it in your app?

Also, just to be clear, the Row Source of your combo looks like this?

In Progress;Completed;Canceled

--
_________

Sean Bailey


Very Basic User said:
Hello Sean,

I've double checked my names field/control names and they all look good. Teh
[Status] is a combo box using a list versus a table or query to pull from it
contains "In Progress, Completed, or Canceled" and the date is a Date/Time
field. When I change from my original code of... just to get a date it works,
but When I changed to yours, I didn't even get a date when changing status to
completed. My code gives me a date but the date time stamp changes every time
I switch from completed to In progress and then back to compelted.

Private Sub Statu_AfterUdate()
If Me![Status]=â€Completed†Then
Me![Actual completion date]=Now()
End if
End Sub


I appreciate your help on this.
--
Thank you for your time!
John


Beetle said:
What I need is... If [Status] is Completed and
[Actual Completed Date] is null, then make actual
completed date = Now()

That's what the code does. I've tested it on my end and it works
as posted.

Are all of your field/control names correct in the code?

Is [Status] a combo box, and if so is "Completed" in the
bound column?

Is [Actual Completed Date] a Date/Time field?
(I was assuming it was but maybe not)

--
_________

Sean Bailey


Very Basic User said:
I tried this code, but it didn't work. Is this saying if [Status] is both
Completed and Null then add todays date? What I need is... If [Status] is
Completed and [Actual Completed Date] is null, then make actual completed
date = Now()
--
Thank you for your time!
John


:

Private Sub Status_AfterUdate()
If Me![Status]=â€Completed†And IsNull(Me![Actual Completion Date]) Then
Me![Actual completion date]=Now()
End if
End Sub

--
_________

Sean Bailey


:

Hello,
I have two fields in my form that I want to interact "Status" and "Date
Completed" the code below gets me close, but does not look for the second
condition that I need it to. What I need in words is... (If Status =
completed and date completed is blank, then change date completed to now. If
both of these conditions are not met, leave the date completed alone. I need
the second condition so that if a user puts the status back to "in progress"
and then changes it back to completed, I don't want the original completed
date to change.

Thanks in advance for your help!

Private Sub Status_AfterUdate()
If Me![Status]=â€Completed†Then
Me![Actual completion date]=Now()
End if
End Sub
 
V

Very Basic User

Thats correct, no date...The value list for status looks like you have it. My
code is exactly as you typed it...
Private Sub Status_AfterUdate()
If Me![Status]=â€Completed†And IsNull(Me![Actual Completion Date]) Then
Me![Actual completion date]=Now()
End if
End Sub
Really weird... I did get another responce from a different area that I just
tried...
Private Sub Status_AfterUpdate()
Select Case Me.Status
Case "Completed"
If IsNull(Me.[Actual completion date]) Then
Me.[Actual completion date] = Now()
Else
End If
Case Else
End Select
End If

I'm not sure why or how, but this code worked exactly how I needed it to.

--
Thank you for your time!
John


Beetle said:
Hmmm...

So if you start a new record and select "Complete" in the combo
box, no value gets inserted into the [Actual completion date] field?

Can you post the new code exactly as you have it in your app?

Also, just to be clear, the Row Source of your combo looks like this?

In Progress;Completed;Canceled

--
_________

Sean Bailey


Very Basic User said:
Hello Sean,

I've double checked my names field/control names and they all look good. Teh
[Status] is a combo box using a list versus a table or query to pull from it
contains "In Progress, Completed, or Canceled" and the date is a Date/Time
field. When I change from my original code of... just to get a date it works,
but When I changed to yours, I didn't even get a date when changing status to
completed. My code gives me a date but the date time stamp changes every time
I switch from completed to In progress and then back to compelted.

Private Sub Statu_AfterUdate()
If Me![Status]=â€Completed†Then
Me![Actual completion date]=Now()
End if
End Sub


I appreciate your help on this.
--
Thank you for your time!
John


Beetle said:
What I need is... If [Status] is Completed and
[Actual Completed Date] is null, then make actual
completed date = Now()

That's what the code does. I've tested it on my end and it works
as posted.

Are all of your field/control names correct in the code?

Is [Status] a combo box, and if so is "Completed" in the
bound column?

Is [Actual Completed Date] a Date/Time field?
(I was assuming it was but maybe not)

--
_________

Sean Bailey


:

I tried this code, but it didn't work. Is this saying if [Status] is both
Completed and Null then add todays date? What I need is... If [Status] is
Completed and [Actual Completed Date] is null, then make actual completed
date = Now()
--
Thank you for your time!
John


:

Private Sub Status_AfterUdate()
If Me![Status]=â€Completed†And IsNull(Me![Actual Completion Date]) Then
Me![Actual completion date]=Now()
End if
End Sub

--
_________

Sean Bailey


:

Hello,
I have two fields in my form that I want to interact "Status" and "Date
Completed" the code below gets me close, but does not look for the second
condition that I need it to. What I need in words is... (If Status =
completed and date completed is blank, then change date completed to now. If
both of these conditions are not met, leave the date completed alone. I need
the second condition so that if a user puts the status back to "in progress"
and then changes it back to completed, I don't want the original completed
date to change.

Thanks in advance for your help!

Private Sub Status_AfterUdate()
If Me![Status]=â€Completed†Then
Me![Actual completion date]=Now()
End if
End Sub
 

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