Solved In a continuous form : Disable / lock a textbox on a specific record on clicking a button within that record. Any way it can be done ?

alan2013

Registered User.
Local time
Today, 09:57
Joined
Mar 24, 2013
Messages
87
I thought it best to post this in 'Forms' rather than 'Modules & VBA'.

In the past (in relation to other databases I've worked on) and again in the last couple of days (for the one I'm working on now), I've conducted research around making formatting etc changes to specific fields in specific records on continuous forms. And I believe the conclusion I've always come to is that conditional formatting can sometimes provide the solution.......not VBA. (Please correct me, if I'm wrong here).

The scenario I'd like to get working now, if it's at all possible :
I have a continuous form embedded in a form. Each record in the continuous form has a text-box and a button (and I'll be adding some other fields; experimenting with the textbox-and-button combo first). I'd like to be able to click on any button I choose, and have the corresponding text-box disable / lock.........not ALL of the text-box on ALL of the records.

IS there a way of doing this in VBA ? Failing that, any other way ? Thanks in advance for any guidance on this.
 
I have used a solution with a hidden text box in the form header to store the primary key values of the selected records. Then create a conditional formatting rule that determines if the current record's primary key is contained in the hidden text box. You would need to have some code in the click of the command button to add or remove the primary key value from the text box.
 
The first thing to know about continuous forms is that only the "current" record in the continuous form is "real." Other records show whatever is there but they are not active. There is only one record-template for a continuous form and it gets re-used for each record displayed by that form. So to disable a button on a continuous form... there is only one button on the record and it only applies to the currently selected/highlighted record in the continuous form.

The "conditional formatting" option would enable you to do shading, add data bars, drop in an icon, or add some kind of computed value. It does not include enabling or disabling something. That enable/disable action would be a VBA function. Take a look in the "Similar Threads" section as a place where you might get some ideas. I've never used conditional formatting for anything except highlighting a color.
 
@The_Doc_Man
Sorry, but that isn't correct.
Conditional formatting can be used to selectively disable controls. There is a (not very obvious) disable button on the CF wizard.
However, CF cannot be used to lock/unlock or show/hide controls . . . more is the pity!

@alan2013
You should be able to achieve what you want if clicking the button sets the value of a variable or field true/false
You can then use the CF wizard to apply that condition to the textbox

As it is a continuous form, it is very unlikely you could do this using VBA
Having said that you might be able to achieve an even better solution using transparency. See my article:

 
Conditional formatting does allow disabling. In the following form, I have set up conditional formatting based on even or odd CompanyID values.

1745957387691.png



1745957303231.png
 
Darn, guess I missed that "very not obvious" disable option - though the online article I found also didn't mention it, and I never tried to use that feature myself.
 
Using a combination of a hidden text-box, conditional formatting (based on the contents of the hidden text-box) and some VBA, I reckon I've achieved what I set out to do.

Thanks to you all.
 

Users who are viewing this thread

Back
Top Bottom