Date changing in a Form

G

Guest

I'm not that famaliar iwth creating expressions so if someone can please help
me with this problem I would greatly appreciate.

I have a form that has "Status" field. When I change the status to
"Terminated" I would like for "today's date" to populate in that field and
also in the "Last status change date" field. Also when I change the status
to "Shipped" I would like for "today's date" to populate in the "Shipped
Date" field and the "Last Status change date" field.

How can I accomplish this task?
 
D

Douglas J. Steele

Put code into the field's AfterUpdate event to set those fields.

Something like:

Private Sub Status_AfterUpdate()

If Me.Status = "Terminated" Or Me.Status = "Shipped" Then
Me.[today's date] = Date()
Me.[Last status change date] = Date()
End If

End Sub
 
G

Guest

You can use the After Update event of the status control to do this. You
post says you want "that field" to be populated with the current date. What
field is "that field"? It can't be the status field.

Basically you would use something like this:

Private Sub Status_AfterUpdate()
If Me.Status = "Terminated" Then
Me.[Last status change date] = Date
ElseIf Me.Status = "Shipped" Then
Me.[Last status change date] = Date
Me.[Ship Date] = Date
End If
 
G

Guest

This works prefect. Another question:
I have another form called Purchase Orders and in this form there is a
subform that is the "Assets" table. In the Assets table there is also the
same fields below (Status, Last status change date, shipped date and
terminated date). If the user uses this form (Assets) to change the status I
want the dates to populate and it is not doing it. How can I put this same
expression in the table or in the subform in order for it to work?

Klatuu said:
You can use the After Update event of the status control to do this. You
post says you want "that field" to be populated with the current date. What
field is "that field"? It can't be the status field.

Basically you would use something like this:

Private Sub Status_AfterUpdate()
If Me.Status = "Terminated" Then
Me.[Last status change date] = Date
ElseIf Me.Status = "Shipped" Then
Me.[Last status change date] = Date
Me.[Ship Date] = Date
End If
--
Dave Hargis, Microsoft Access MVP


dplove said:
I'm not that famaliar iwth creating expressions so if someone can please help
me with this problem I would greatly appreciate.

I have a form that has "Status" field. When I change the status to
"Terminated" I would like for "today's date" to populate in that field and
also in the "Last status change date" field. Also when I change the status
to "Shipped" I would like for "today's date" to populate in the "Shipped
Date" field and the "Last Status change date" field.

How can I accomplish this task?
 

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