cannot change date in a feild

hi

this works great

Code:
Me.Target_Date.Locked = Not IsNull(Me.Target_Date)

but trying to see what other options you all kindly send me I am trying you e different comments

@ridders
I cannot get passed this code




Code:
 cmdQuit.SetFocus

my control is "Target_date

steve
 
Last edited:
hi

this works great

Code:
Me.Target_Date.Locked = Not IsNull(Me.Target_Date)

but trying to see what other options you all kindly send me I am trying you e different comments

@ridders
I cannot get passed this code

Code:
 cmdQuit.SetFocus

my control is "Target_date

steve

As stated in my last post:
Sounds like you don't have a cmdQuit button so the code throws an error.
If you don't have that button, delete that line of code ...or set focus to another control if you wish
 
On this occasion, you are incorrect
No, not this time. When you use VBA to set properties, you MUST toggle them otherwise, once they are set, they stay set unless you close and reopen the form.
Continuous form #2 uses your If ...Else..End If code
Interestingly it gives exactly the opposite of the results the OP wants
THAT was the mistake. I had the true/false paths backwards.
 
No, not this time. When you use VBA to set properties, you MUST toggle them otherwise, once they are set, they stay set unless you close and reopen the form.
THAT was the mistake. I had the true/false paths backwards.

I agree you had that code the wrong way round, though as I said, it's counter intuitive as it looked correct.

Nevertheless, I suggest you look at the example I uploaded in post #17.
The code does work....
 
Just to be a bit pedantic:

Code:
If IsNull(Me.somecontrolname) = True  Then
    Me.somecontrolname.Locked = True
Else
    Me.somecontrolname.Locked = False
End If

works fine. So does this. But is less typing.

Code:
Me.somecontrolname.Locked = IsNull(Me.somecontrolname)
 
Nevertheless, I suggest you look at the example I uploaded in post #17.
The code does work....
Colin, your code is also toggling the value. The difference is that you have used two different methods. The "slick" method to toggle the locked property and the mundane IF to toggle the color. For ease of understanding I used the same expression to toggle both properties. The issue is not the locked property since the original expression toggles that as long as the code is in the current event. The problem arises once you add the color change.
 
Gents

what I have learned in the last 2 days , and today is NEVER put spaces in names . or change the name in the table

thanks you all for help

steve
 
Colin, your code is also toggling the value. The difference is that you have used two different methods. The "slick" method to toggle the locked property and the mundane IF to toggle the color. For ease of understanding I used the same expression to toggle both properties. The issue is not the locked property since the original expression toggles that as long as the code is in the current event. The problem arises once you add the color change.

Yes I'm fully aware of that Pat.
The colour formatting was a quick and 'dirty' method to show rainbows the state of the control. It isn't needed and indeed I suggested removing it in a continuous form as it is confusing.
Of course, if the colour formatting is wanted, setting one of the colours as default means that can be toggled in one line.

My point was that the IsNull line does all that is necessary.... as was originally stated by ranman in post #2 and expanded upon by myself.
Despite your assertion in post #16, there is absolutely no need for If..Else..End If code in this case....though of course there's nothing wrong with using it either
Doc wasn't being pedantic in post #25. He was pointing out that using IsNull is effectively just a more concise version which does the same thing in this scenario.
 
gents

I have found a problem and I don't know if it another thread or not
But
If I run a query with "targetdate" in it I can edit that date . can we stop that?
took out the spaces are suggested


thanks
steve
 
It really should be a separate thread, but just as an FYI, locking controls on a form does nothing to affect query behavior. They are two separate objects that fill two entirely different roles.
 
If I run a query with "targetdate" in it I can edit that date . can we stop that?


Um, don't run the query. And don't open the table and edit there either.


We put business rules in forms where we can limit users on what they can do to data and do not provide means to enable users to run queries to change data not meant to be changed.


If you want to provide table level rules, you'll need a database engine other than what is provided with Access.
 
Agree with cronk

In normal use, tables are meant to be editable.
It is possible to make tables read only but this isn't standard practice.

However, end users should never have direct access to tables or queries.
All interaction should be using forms with reports used to display outputs
 

Users who are viewing this thread

Back
Top Bottom