Results 1 to 15 of 15
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    control locking (97)

    control locking
    in my form I

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: control locking (97)

    With only 4 controls, I'd just call a sub from the form's Current Event. The sub would then specifically lock/unlock these 4 controls by name, rather than trying to cycle through the control collection.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: control locking (97)

    well Mark I took you

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: control locking (97)

    >> You wrote:
    Private Sub lockControl(controlName As control)
    controlName.Enabled = False
    controlName.Locked = True
    End Sub

    Problem though is that when lockControl is called, controlName contains a 0! It doesn
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: control locking (97)

    my mistake Mark, I shouldn

  6. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: control locking (97)

    I don't understand why this isn't working for you. I tried it and it works perfectly. And you are sure the code is executing. That is, you set a breakpoint at one of the lines within "lockcontrol", and execution stopped at that line?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  7. #7
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: control locking (97)

    Mark,
    I actually set a breakpoint in the calling procedure, formCurrent and it called the lockFunction twice and executed each part of the function. Since controlName contains 0, ofcourse nothing happened, but on the same coin, there was no error message, its just that nothing was locked in the end.

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: control locking (97)

    What kind of controls are you passing? And what do you mean by "it doesn't contain the control names"? You aren't passing a control name, you're passing the control itself, so if you reference the control, it returns the value in that control. What does x=5 have to do with it?
    Charlotte

  9. #9
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: control locking (97)

    passing controls on my form, they're just text boxes & in my back & forth w/Mark above i'm not passing control names, but the controls themself.

    x=5 helps determine which of my various controls to lock, i have conditions 1 to 4 also & they are not bothering my progress, its the fact that although i'm passing a control (a text box) the called function is not receiving them, its getting a 0 instead.

  10. #10
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: control locking (97)

    When you say the ControlName contains 0, exactly how are you ascertaining that? The value of ControlName will be the value of the control it points to. And you said the control wasn't locked, which I take to mean that you clicked on that control and it allowed entry into the field? Did it allow you to change it?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  11. #11
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: control locking (97)

    when the lockControl function is called I

  12. #12
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: control locking (97)

    No, the fact is that the value of the textbox you're passing is zero, for whatever reason. Did you set values in those textboxes prior to this point? Are they bound textboxes with defult value, or what?

    When you step through the code, come to this line and hover your cursor over the control name ...

    Call lockControl(Me.ForecastHST)

    ... you should see the value being passed in the control. Is that where you're seeing a zero? Does that differ from the value displayed on the form? And what does the value of the control have to do with anything? All you want to do is disable and lock it (by the way, you've got that in the wrong order--lock first, then disable), what is the significance of its value?
    Charlotte

  13. #13
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: control locking (97)

    >>since my .enabled=false condition ought to have
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  14. #14
    New Lounger
    Join Date
    May 2002
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: control locking (97)

    I think the problem with your code is that you are passing the value of the control, not the control itself. Have you tried:

    Call lockControl(me.controls("ForecaseHST"))?

  15. #15
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: control locking (97)

    There is no difference (except speed) between Me.Controls("controlname") and Me!ControlName or even [ControlName]. Any of them will pass the control, which has its value as the default property.
    Charlotte

Posting Permissions

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