Help changing control values based on other control values please

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

Guest

Good Morning,
I want to change the values of several controls on a form based on the
value of a single control; but, have the ability to change the value back.
Here is a simplified version of what I am trying to accomplish:

Christmas Shopping List Form
Done Christmas shopping? Y/N (all check boxes)
Have husband's gift? Y/N
Have daughter's gift? Y/N
Have dog's gift? Y/N

As going through gifts, check of Husband's, then daughter's, then determine
all done and check Done, changing the Dog's gift to true as well. (no
troubles with this part)

Then realize I already gave him that bone, so I need a new gift, and then
unselect Done. I would like the values to revert to Husband's true,
daughter's true, dog's false. I would appreciate any support and references.

Thanks in advance, and Happy Holidays :)
Renee
 
On the Done AfterUpdate event:

Private Sub Done_AfterUpdate()

Dim varHGift, varCGift, PGift as Variant
varHGift = Me.HGift.Value 'Assign the current value before any
changes
varCGift = Me.CGift.Value
varPGift = Me.PGift.Value
If (Me.Done.Value = True) Then 'All done shopping, make all true
Me.HGift.Value = True
Me.CGift.Value = True
Me.PGift.Value = True
Else 'Not done shopping, reset all
values
strMsg = "Would you like to revert to your previous selections?"
strMsg = strMsg + " If you select no, all boxes will be unselected"
If (MsgBox(strMsg, vbQuestion + vbYesNo, "Revert?") = vbYes) Then
Me.HGift.Value = varHGift 'Revert to previous value
Me.CGift.Value = varCGift
Me.PGift.Value = varPGift
Else 'Reset boxes to false
Me.HGift.Value = False
Me.CGift.Value = False
Me.PGift.Value = False
End If
End If

End Sub

When I select Yes on the Msg box, it changes everything to false.
When I select No on the Msg box, it changes everything to false.
I put in additional text boxes to test if it recognizes the yes, and no.
When I select yes, the resulting box was "Selected Yes", but then made the
values false, regardless of what was there prior to changing the "Done".
When I select no, the resulting box was "Selected No", but then made the
values false (as it should).

Any suggestions for changes would be great.
Renee

P.S. anyone happen to know how to force a carriage return between the above
message lines?
 
Back
Top