default value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • n8kindt
    New Member
    • Mar 2008
    • 221

    default value

    consider this scenario:

    there are 2 text boxes in a form. "Text1" is unbound. "Text2" is also unbound.

    Text2, however, has its default value set to: =Nz([Text1],0) + 8

    let's say a user types "2" into Text1. what vba command do i use to to "refresh" Text2 to properly display its current default value of "10"??

    i know this seems like a stupid question but i couldn't immediately find anything by searching :-/... could someone kindly point me in the right direction?

    thanks guys,
    nate
  • Scott Price
    Recognized Expert Top Contributor
    • Jul 2007
    • 1384

    #2
    Code:
    Me.Repaint
    should do it.

    Regards,
    Scott

    Comment

    • n8kindt
      New Member
      • Mar 2008
      • 221

      #3
      Originally posted by Scott Price
      Code:
      Me.Repaint
      should do it.

      Regards,
      Scott
      thanks for your reply, scott. hmmm i tried placing that code in the AfterUpdate, GotFocus, and Change events of both text boxes and nothing seems to happen. i'm guessing Me.Repaint will refresh the textbox in which the OnEvent code is placed. so if i placed this code in a Text1 Event, wouldn't i need a separate code for Text2? what i'm thinking is i need a code to place in the AfterUpdate event of Text1 which repaints Text2.

      something tells me there's a better way to do this strictly through vba--bypassing the default value thing. something like
      Code:
      text2.value = text1.value + 2
      (try not to laugh too hard at my feeble attempt at generating vba code with only a small knowledge of the language :) )...
      as is, i don't think that code would return anything and also, i have no idea where to place that code once it works.

      Comment

      • n8kindt
        New Member
        • Mar 2008
        • 221

        #4
        ok, i figured it out. that's funny, i guessed right!

        for future reference, this is the code i used
        Code:
        Private Sub Text1_AfterUpdate()
        Text2.Value = Text1.Value + 2
        End Sub

        Comment

        • Scott Price
          Recognized Expert Top Contributor
          • Jul 2007
          • 1384

          #5
          You're doing fine :-)

          I think your solution is better also...

          Glad you figured it out!

          FYI when in the VBA editor window, position the cursor within any word and press F1 to bring up the specific help topic for that word... You probably know this already, but just in case.

          Regards,
          Scott

          Comment

          Working...