Storing values in fields based on other field with checkbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jdfergus
    New Member
    • Jun 2010
    • 14

    #1

    Storing values in fields based on other field with checkbox

    Hello, I have a field "MappedTo" in a subform "OldCodes" thats needs to refer to a field "NCodes" in the main form "NewCodes" based on whether a field in the subform "Decision" is checked or not. I would like it so when a user clicks the checkbox for "Decision", "MappedTo" is automatically updated with whatever the current "NCode" is in the main form. I can sorta do this by using

    IIf([Decision]=-1,Forms!NewCode s![NCodes]," ")

    as the control source for "MappedTo", but this gives me a problem. Each "old code" in the subform can possibly map to multiple "new codes" in the main form, but I would like the resulting value from the function to be the same throughout each record, and not recalculated each time it appears. Also I am having trouble storing this value in its underlying table.

    In short, I need to know how to store a calculated if-then field to an underlying table, and for the calculation to only be performed on the actual click of the checkbox, not if a checkbox is already clicked or not.

    I've messed around with several BeforeUpdate, AfterUpdate, and OnClick codes as well as trying to store in hidden textboxes, but keep getting errors. Please help, thanks to anyone who can.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    I suggest you use the Decision_AfterU pdate() event procedure in your sub form to set Me.MappedTo to Me.Parent.NCode.

    Comment

    • jdfergus
      New Member
      • Jun 2010
      • 14

      #3
      Thanks for the response, I think that might have helped it but I've been given some new requirements and come up with a whole new seperate problem, lol. Thanks for the help though.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        No worries :)

        If you have a separate problem you may want to post that too.

        Comment

        Working...