Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Pennsylvania, USA
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've search high and low.

    How would I go about disabling a Forms Control if the Control is not Null?

    What I have is Form with a Created Control which should have a date if the record is new. I have a Button for the user to open a calendar form that places the date into the Control. After the Control is updated with a date I want the Control and button to be disabled and view the Controls contents

    As a second question with this I have a Last Updated Control that when the record is updated I would like the date to populate the Control automatically.

    Can someone point me the direction of an answer

    Access 2002 will be moving to 2007
    threecrow

    Don't make excuses. It's what you do, not why you didn't.

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    You can Disable a Control using this line of code
    Code:
    me.controlname.enabled=false
    Disabled controls look grey. If you don't want it to look grey, then lock it when you disable it.

    Code:
    me.controlname.locked=true
    You need to put this code in two places.

    • Normally you use the After Update event of what you want to trigger it. But in this case you are doing that via a button, so the after update event will not fire. So you need to tack in on the end of the code that puts the date in.
    • The On Current of the form as well. This is so the control is locked when you revisit existing records. But here you need to enable/disable selectively.
    Code:
    if isnull(me.controlname) then
    me.controlname.enabled=true
    me.controlname.locked=false
    else
    me.controlname.enabled=false
    me.controlname.locked=true
    end if
    The Form itself has an After Update event. Use that to set the value of the Last Updated Control

    Code:
    me.[last updated] = Date
    Regards
    John



  3. #3
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Is the last updated control a BOUND or an UNBOUND Control

    If it is Bound to a Field on the underlying recordset, you need to use the FORMS BEFORE UPDATE Event to set its value.

    If it is Unbound After Update is Fine.
    Andrew

Posting Permissions

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