update one field based on the value of another

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi. I have 2 fields that I want to be dependent on each other. The first one
is a yes/no. the second is a date. So when the user clicks on the checkbox,
i want the date to fill in automatically.
Can this even be done? I know it can be done on a record change, but I am
just not sure
Thanks in advance for any help
 
Casandra,

Yes, you could do this. You could assign a macro on the After Update
event of the checkbox. This would use a SetValue action, with these
arguments...
Item: [NameOfYourDateControl]
Expression: Date()

This assumes that you meant the current date to be entered.

You may also need to consider what happens if the checkbox is unticked
again - should the date be removed?

However, I should also say that this probably flouts database design
principles. It sounds like the data entry will be redundant. If it is
the case that the yes/no field will always be Yes if there is a date
entered, and always be No when there is no date entered, and conversely
there will always be a date entered when the yes/no field is Yes, then
you should dispense with the yes/no field altogether, and use some other
means of entering/updating the date field.
 
Thanks very much for your help, that is exactly what I need to be done, if
the box is unchecked, I need for the date to go away. I know that this
doesn't happen. Do you have any suggestions as to how to handle this issue?
I am really stuck, since I have a bunch( 8 or more) fields that I need this
control done t. If they click the box saying they completed an action item,
I need a date the analyst can't change( for quality control).

I appreciate all of your help.


Steve Schapel said:
Casandra,

Yes, you could do this. You could assign a macro on the After Update
event of the checkbox. This would use a SetValue action, with these
arguments...
Item: [NameOfYourDateControl]
Expression: Date()

This assumes that you meant the current date to be entered.

You may also need to consider what happens if the checkbox is unticked
again - should the date be removed?

However, I should also say that this probably flouts database design
principles. It sounds like the data entry will be redundant. If it is
the case that the yes/no field will always be Yes if there is a date
entered, and always be No when there is no date entered, and conversely
there will always be a date entered when the yes/no field is Yes, then
you should dispense with the yes/no field altogether, and use some other
means of entering/updating the date field.

--
Steve Schapel, Microsoft Access MVP

Hi. I have 2 fields that I want to be dependent on each other. The first one
is a yes/no. the second is a date. So when the user clicks on the checkbox,
i want the date to fill in automatically.
Can this even be done? I know it can be done on a record change, but I am
just not sure
Thanks in advance for any help
 
Casandra,

Use a Condition in your macro. If you can't see the Condition column in
the macro design window, select it from the View menu.

Condition: [NameOfCheckbox]=-1
Action: SetValue
Item: [NameOfYourDateControl]
Expression: Date()

Condition: [NameOfCheckbox]=0
Action: SetValue
Item: [NameOfYourDateControl]
Expression: Null
 
Back
Top