Update Date Field based on Option Box Criteria

J

Jennifer

I have an option box with two options Open =-1 and Closed =1.

Open is the default value.

When an end user clicks on Closed I want two changes to automatically happen:
1. I want the closed date to change to (now) and
2. I want the value in the status combo box to change to "Completed"

Can anyone give me sample code to make this happen and tell me where to
place the code.

Thanks,
Jennifer
 
J

John W. Vinson

I have an option box with two options Open =-1 and Closed =1.

Open is the default value.

When an end user clicks on Closed I want two changes to automatically happen:
1. I want the closed date to change to (now) and
2. I want the value in the status combo box to change to "Completed"

Can anyone give me sample code to make this happen and tell me where to
place the code.

Thanks,
Jennifer

You can put the code in the optino group's AfterUpdate event. Select the
option group control in form design view; view its Properties; and find the
After Update event on the Events tab. Click the ... icon and choose Code
Builder. Access will give you the Sub and End Sub lines; edit to something
like (I'm making assumptions about your form control names):

Private Sub optOpen_AfterUpdate()
If Me!optOpen = -1 Then
Me!txtClosedDate = Date() ' or Now() if you want the date & time
Me!cboStatus = "Completed"
End If
End Sub

This will not reverse changes if the user changes to Closed and then back to
Open - I don't know what you want to happen in that case!
 
J

Jennifer

The original complete date won't change, but the status should change back to
open
 
J

John W. Vinson

The original complete date won't change, but the status should change back to
open

Then use code like

If Me!optOpen = -1 Then
<do something appropriate for -1>
Else
<do something appropriate for 1>
End If
 

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