Update field when another field is updated

G

Guest

I have a customer form. There is one field that is a lookup so we can denote
if the customer is active or inactive.
When a new customer is added I have a date field that records this date
(date()) as the default value.
When I change the customer status from active to inactive I want this date
field to automatically update to the date when the status is changed.
How can I do this?
Thanks
 
D

Douglas J. Steele

In the AfterUpdate event of the Status field, put code that updates the Date
field. If I'm understanding correctly, your Status field is a combo box, so
you'd use something like:

Private Sub cboStatus_AfterUpdate()

If Me.cboStatus = "Inactive" Then
Me.txtLastUpdate = Date
End If

End Sub
 
G

Guest

Dear Douglass,

I am putting in the code:

Private Sub InmateStatus_AfterUpdate()
If Me.InmateStatus = "Inactive" Then
Me.Text37 = Date
End If

End Sub

this is actually not for customers but for a prison ministry newsletter I do
for our church,that is why you see inmates used
Text37 is where the date information is stored. You are right that the
status field is a combo box, however with this code the date field (Text37)
does not update.
any more suggestions?
thanks
 
D

Douglas J. Steele

Try putting the line of code

MsgBox Me.InmateStatus

in that routine before the If statement.

It's possible that the bound field for your combo box returns something
other than Active or Inactive.
 
G

Guest

Dear Doug,
I hate to keep bothering you but I still cannot get this to work. Yes, you
are correc that I have more then active and inactive in the combo box. There
is also released for inmates that are released (obviously). Only these three
choices.

When I added the code
MsgBox Me.InmateStatus
before the IF statement the date field (Text37) would not update when I
changed an inmate from Active to Inactive. What would happen is that a
message box would pop up saying, "1" (for Active) or "2" for Inactive.

Any other suggestions? I am not good with VBA so I am pretty lost.
thanks
Jerry
(e-mail address removed)
 
D

Douglas J. Steele

The message box did exactly what it was supposed to: it showed that
Me.InmateStatus isn't returning the word Inactive, which is what the code
was expecting.

Sounds as though what you want is:

Private Sub InmateStatus_AfterUpdate()
If Me.InmateStatus = 2 Then
Me.Text37 = Date
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