Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a form A which contains a sub-form A-sub; this subform contains a date, A-date.
    When a command button on form A is clicked, a second form B is opened; this also contains a subform, B-sub, containing a date, B-date.
    Form A remains loaded.
    If B-date is altered, I need to check that it is not earlier than A-date in the Before Update routine for field B-date.

    I've tried setting up a public variable in the VBA for module A, copying A-date to it when the command button is clicked and testing it in the B-date VBA routine but it doesn't work.
    I've declared it as PUBLIC EarliestDate as Date.

    What am I doing wrong, please?

    Thanks
    Silverback
    Silverback

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    I typically do that as a GLOBAL in a standard module of some sort so it is always available - it seems what you've done should work, but you could try making it GLOBAL in your subform module and see if that works.
    Wendell

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    If, as you say, form A remains loaded then you can check the value of A-date directly without needing a variable to do so.

    Alternatively you can pass the date value to form B using OpenArgs. This also avoids the need to a public module level variable.
    Regards
    John



  4. #4
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, both. All working OK, now.
    I used the Public variable method as I already had a module containing some general functions.

    Silverback
    Silverback

Posting Permissions

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