Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Clear Contrents Of a Control (2002)

    When I use a maco go to control password, run command delete. I get any error message that the control is not selected. humm.. how could that be? I just want to clear the password with I close the form.
    Frank

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

    Re: Clear Contrents Of a Control (2002)

    Why clear a control if you're closing the form it's on anyway? There doesn't seem to be much point in that...

    In general, if you want to clear a control, you don't need to set focus to it. Just use

    <font face="Georgia">controlname = Null</font face=georgia>

    where controlname is the name of the control to be cleared.

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Clear Contrents Of a Control (2002)

    Hi Hans,
    I have a field I use for a password and want to clear the password everytime the form and database is closed.
    Frank

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Clear Contrents Of a Control (2002)

    Private Sub Form_Close()
    Password = Null
    End Sub
    I get a runtime error that says I can't assign a value to this object.
    Frank

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

    Re: Clear Contrents Of a Control (2002)

    Do you close the form by clicking a close button? If so move the line of code
    password = Null
    so that it executes before the docmd.close action.

    I think the problem relates to sequence of events. the Unload event occurs before the close event, so that data from the form has already been unloaded.

    You could try putting
    password = Null
    in the unload event. That seems to work
    Regards
    John



  6. #6
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Clear Contrents Of a Control (2002)

    You can't assign a value to a control on form's Close event. Try using Unload event instead. The Unload event can be cancelled, while the Close event cannot.

    HTH

  7. #7
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    That works!

    I provided a quit button but have been using the forms close button, I sulute you on your astute grasp of the form events sequence-I was not thinking of that and just thought the form just closes.
    Frank

Posting Permissions

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