Locking or Unlocking a form control based on input.

Doesn't seem to like that Me! command because the Form is using a table and I am using a query to obtain the person and level. I think I need to somehow refer to the non-form related query.
 
Run-time error '94'.
Invalid use of Null

My form uses my "Orders" table which contains all the records that are being created and has a field called "Order Type". My "Query Orderers" which goes against my "Orderers" table which contains the list of people with their access level also has a field called "Order Type". I thing the Me! command is looking at the Orders table that the form uses instead of the query.
 
If level is the second column wouldn't it be:

mytxtbox.Locked = (Me.Mylevelcombobox.Column(1) = "Low Level")
 
Changing it to that gives me a compile error:, syntax error.
 
If level is the second column wouldn't it be:

mytxtbox.Locked = (Me.Mylevelcombobox.Column(1) = "Low Level")
Apparently it's not in the combo box, it's just a field.

If it's pointing to Null then:

mytxtbox.Locked = (Nz(Me![FieldNameOfLevel], "") = "Low Level")
 
Apparently it's not in the combo box, it's just a field.

It would be good to see the actual thing then because I took my response given the OP's post from #19:
is because the level combo box is bound to the person's name but set to display the level.
 
Okay, just as I suspected, the mytxtbox.Locked = (Nz(Me![FieldNameOfLevel], "") = "Low Level") is looking for "FieldNameOfLevel" in the table that the form is based on and not my query that I use to obtain the person's name and level. I changed the field names so they were not the same in the table and query, and now I get:

Run-time error '2465'.
Microsoft Access can't find the field 'MyLevelFieldInMyQuery' referred to in your Expression.

I need to somehow refer directly to my query by name and then the level field within the query.
 
We would be going round in circles because it's seems you aren't conversant with certain properties of controls/objects in Access. On that note we can't really advise further unless we could:
...see a stripped down version of your db then I could advise what your next steps would be.
...see the actual thing then because I took my response given the OP's post from #19:

A stripped down version without any sensitive data (but with erroneous data) will do.
 
Okay, here it is. Low level (locked field) = "Tech", high level (unlocked field) = "RPh".
 

Attachments

It works. Thank you vbaInet!!! Can you tell me what the key was to making it work for future reference?

Don
 
You had too many events overriding it and as SOS mentioned you needed Column(1). Take note of the events that the code was placed.

You're welcome.
 

Users who are viewing this thread

Back
Top Bottom