combo box lock

krzysiekk

Registered User.
Local time
Yesterday, 23:20
Joined
Dec 2, 2009
Messages
74
Hi,

Is any chance to lock combo box at 7am and unlock at 14pm??

Please help me and show any example.

I try something like:
Me.controlname.Locked=True

but I don't know how use function IIF with time
 
Last edited:
Just swagging here ....

Code:
If Time() > #7:00:00 AM# AND Time() < #2:00:00 PM# Then
      'do enable
Else
      'inhibit enable
End If

This might be dependant on the way the system date/time is setup. Just throwing out a guess for you.

-dK
 
If Time() > #7:00:00 AM# AND Time() < #2:00:00 PM# Then
'do enable
Else
'inhibit enable
End If

Not working
 
Not working

Did you revise your code to include the locked part? But here's a shorter method:
Code:
Me.ControlName.Locked = (Time() > #7:00:00 AM# AND Time() < #2:00:00 PM#)

But you'll probably need to enable the form's timer and have it check every so often so that when that time rolls around it will not be enabled.
 
Nice nugget there, Bob. Who'da knew?

krzysiekk,

I just validated this using Bob's post and added a label for visual verification. I added this code on the OnCurrent event of the form so I could cycle through records to see the label caption change as I modified the end time ...

Notice that I did this to 2 different fields to also validate the code. One was locked and other was not.

Code:
    Me.A.Locked = (Time() > #7:00:00 AM# And Time() < #3:00:00 PM#)
    Me.B.Locked = (Time() > #7:00:00 AM# And Time() < #2:00:00 PM#)
    
    
    If (Time() > #7:00:00 AM# And Time() < #2:00:00 PM#) Then
        Me.lblNotify.Caption = "Locked"
    Else
        Me.lblNotify.Caption = "Unlocked"
    End If

- dK
 
Nice nugget there, Bob. Who'da knew?
Well, I sure didn't for the longest time. Since I've found out how to do that, I've been watching for things like this where I can take 6 or 7 lines of code down to just 1. :)
 
Amen! It's definitely going down in my book.

I am trying to withhold myself from going through a buncha stuff to see if I can implement right away. :D

I am sure someone will want to add something new at which point I can take advantage of it.

-dK
 
The key is setting it up so that the calculation either returns a true or false. So, if you had 6+7 = 14 that would return False. But you also have to use the parens on it so it doesn't think you are trying to assign the calculation itself to it.
 

Users who are viewing this thread

Back
Top Bottom