Trouble w/checkboxes and macros

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Zulema
    New Member
    • May 2007
    • 44

    Trouble w/checkboxes and macros

    I have several text boxes on a form that are populated with certain values depending on the value chosen on a combo box. These textboxes are populated with currency values with help of macros. Problem is that I also have a check box that when checked must populate the last textbox with a value of "0" and disregard the value assigned by macro, but only when checked. If the user unchecks the box then the macro must run and assign its value. The first part works fine. When the checkbox is checked it assigns "0", but when it is unchecked it returns and Action Failed on the macro. How can i make this work? I hope i have made myself clear. What i have so far this on the after update on the checkbox:

    If Me.EXEMPTED_DED UCTION.Value = True Then
    Me.DEDUCTIONS.V alue = 0
    Else
    DoCmd.RunMacro "McrDefaultValu e"
    End If
    End Sub
  • PianoMan64
    Recognized Expert Contributor
    • Jan 2008
    • 374

    #2
    Originally posted by Zulema
    I have several text boxes on a form that are populated with certain values depending on the value chosen on a combo box. These textboxes are populated with currency values with help of macros. Problem is that I also have a check box that when checked must populate the last textbox with a value of "0" and disregard the value assigned by macro, but only when checked. If the user unchecks the box then the macro must run and assign its value. The first part works fine. When the checkbox is checked it assigns "0", but when it is unchecked it returns and Action Failed on the macro. How can i make this work? I hope i have made myself clear. What i have so far this on the after update on the checkbox:

    If Me.EXEMPTED_DED UCTION.Value = True Then
    Me.DEDUCTIONS.V alue = 0
    Else
    DoCmd.RunMacro "McrDefaultValu e"
    End If
    End Sub
    Can you please post what is in the Macro as well?

    This will help in troubleshooting your problem.

    The obvious comment that I have so far is use the OnChange Event instead of the AfterUpdate event. The onChange Event fires right as you change it. not after the record is updated. This may be to late for what you're wanting to accomplish.

    Write me back on the forum and let me know once you have the macro posted.

    Thanks,

    Joe P.

    Comment

    • Zulema
      New Member
      • May 2007
      • 44

      #3
      Thank you! It worked! I changed it to the on change event and it worked wonderfully!

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        I'm glad that you got it working, but there's absolutely no reason why it shouldn't have worked in the checkbox's AfterUpdate event! A control's AfterUpdate fires before the record is saved, while the record is still Dirty. For a textbox, this occurs when the focus leaves the textbox for another control. For a checkbox the AfterUpdate fires as soon as it's checked/unchecked.

        There's another problem that you haven't addressed, at least not here. If the user checks the box, zero is assigned. If they then uncheck the box, the textbox is populated by your macro. But what happens if the user simply does nothing with the checkbox? How is the textbox populated then?

        Linq ;0)>

        Comment

        • Zulema
          New Member
          • May 2007
          • 44

          #5
          Originally posted by missinglinq
          I'm glad that you got it working, but there's absolutely no reason why it shouldn't have worked in the checkbox's AfterUpdate event! A control's AfterUpdate fires before the record is saved, while the record is still Dirty. For a textbox, this occurs when the focus leaves the textbox for another control. For a checkbox the AfterUpdate fires as soon as it's checked/unchecked.

          There's another problem that you haven't addressed, at least not here. If the user checks the box, zero is assigned. If they then uncheck the box, the textbox is populated by your macro. But what happens if the user simply does nothing with the checkbox? How is the textbox populated then?

          Linq ;0)>
          i have another macro populating this texbox when the checkbox is not checked. It is doing exactly what i need it to do! Many Thanks!

          Comment

          Working...