Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Dec 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Requery controlsource (2000(sr3))

    I have two unbound textboxes on a form. The first is for entering a year, the second has as its controlsource a function a function that turns that year into a date, Jan 1 of the following year. Eg. box 1 = 1997, box 2 is calculated to Jan 1, 1998

    In certain circumstances, I need to change the value in box 1 through VBA and then recalculate box 2. I can't get box 2 to recalculate properly. I've tried Me.box2.Requery and I get #Name? I've tried calling the function in code with the same problem. How do I get the function to be called to reflected the changed value of box 1?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Requery controlsource (2000(sr3))

    If you set the Control Source of box2 to

    =DateSerial([box1]+1,1,1)

    it should be recalculated automatically when box1 is updated, whether manually or through code.

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Requery controlsource (2000(sr3))

    You should not need to do anything at all to get box to recalculate. It should happen automatically.

    What is the control Source of Box2? =DateSerial([box1]+1,1,1)

    Have a look at the attachment.
    Attached Files Attached Files
    Regards
    John



  4. #4
    4 Star Lounger
    Join Date
    Dec 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Requery controlsource (2000(sr3))

    Thanks to both of you. I got it going in a roundabout way through the code.
    My controlsource is a custom function that does exactly what both of you suggest. So, I'll try it your way which is more elegant and if it still won't work properly, I can always revert to my less elegant way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •