Update a seperate field from an update of another field

D

David Sullivan

I have two fields called Contact Tag and Due date

The Contact Tag is a list field with 3 items in it,
Contact again in 6 months, Contact again in 1 month, no
contact again, dependent on which one I choose I want it
to update the next field Due date with a date for contact
in 6 month current date + 256 days; contact in 1 month
means due_date = current date + 30 days, and nocontact
again = leave due_date Null, can anyone suggest a
possible solution I am a access coding novice
 
S

Steve Schapel

David,

Here's one approach... In the After Update event of the Contact Tag
listbox, you can put code something like this...

Private Sub Contact_Tag_AfterUpdate()
Select Case Me.Contact_Tag
Case "Contact again in 6 months"
Me.Due_date = DateAdd("m",6,Date())
Case "Contact again in 1 month"
Me.Due_date = DateAdd("m",1,Date())
End Select
End Sub
 
S

Steve Schapel

Well, at first glance, I thought that you wouldn't need to explicitly
handle the third option, but I have reconsidered. Better to do this...

Private Sub Contact_Tag_AfterUpdate()
Select Case Me.Contact_Tag
Case "Contact again in 6 months"
Me.Due_date = DateAdd("m",6,Date())
Case "Contact again in 1 month"
Me.Due_date = DateAdd("m",1,Date())
Case "no contact again"
Me.Due_date = Null
End Select
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