Solved SetProperty to disable external control

Sarah.M

Member
Local time
Today, 15:56
Joined
Oct 28, 2021
Messages
303
Hi, Plz note, My VBA is blocked by IT for security reason.
I can use only Expression builder, Macros, Queries, Tables, Forms and Reports only.
------------------------------------------------
Hi, I have main form has a button this button open another form in Add Mode, I want to use SetProperty to disable externally Tab1 from that button, I use select object, but still dose not work :(
plz help me to fix it 🙏

Sample attached
 

Attachments

  • 17.accdb
    1.1 MB · Views: 179
Last edited:

Ranman256

Well-known member
Local time
Today, 08:56
Joined
Apr 9, 2015
Messages
4,121
as long as form2 is not modal, use the full path to disable:

open "form2",,,,acFormAdd
forms!form2!tap1.enabled = false
 

June7

AWF VIP
Local time
Today, 04:56
Joined
Mar 9, 2014
Messages
4,459
Your question references Tap1 but I assume you meant Tab1.

Why not set Tab1 as Enabled No in its design then enable it when needed? Have AddNewMeeting form manage its controls. Use combobox AfterUpdate event.

@Ranman256 - already tried that and macro still errors. OP cannot use VBA.
 
Last edited:

Sarah.M

Member
Local time
Today, 15:56
Joined
Oct 28, 2021
Messages
303
as long as form2 is not modal, use the full path to disable:

open "form2",,,,acFormAdd
forms!form2!tap1.enabled = false
Thanks for replying
it dose not work I got error message
plz help

1647245715496.png
1647245677280.png
 

Sarah.M

Member
Local time
Today, 15:56
Joined
Oct 28, 2021
Messages
303
Your questions references Tap1 but I assume you meant Tab1.

Why not set Tab1 as Enabled No in its design then enable it when needed? Have AddNewMeeting form manage its controls.
Thanks for replying
Because I will use 2 buttons
Button 1 it is going to open AddNewMeeting form in Add Mode, if it is in Add mode enabled will be step by step
Button 2 it is going to open AddNewMeeting form in Edit Mode, if it is in Edit Mode everything will be enabled
plz help
 

June7

AWF VIP
Local time
Today, 04:56
Joined
Mar 9, 2014
Messages
4,459
Then set a TempVars variable that indicates which mode is desired and AddNewMeeting checks that variable when it opens and sets its controls appropriately. Use If Then in macro.

Can also use Conditional Formatting to enable/disable textboxes and comboboxes. Conditional Formatting rules can reference TempVars variable.

As far as I can tell, the 'external' reference you want won't work.
 

Sarah.M

Member
Local time
Today, 15:56
Joined
Oct 28, 2021
Messages
303
Then set a TempVars variable that indicates which mode is desired and AddNewMeeting checks that variable when it opens and sets its controls appropriately. Use If Then in macro.

Can also use Conditional Formatting to enable/disable textboxes and comboboxes. Conditional Formatting rules can reference TempVars variable.

As far as I can tell, the 'external' reference you want won't work.
Thanks for replying,
Kindly, do you have sample plz?
 

June7

AWF VIP
Local time
Today, 04:56
Joined
Mar 9, 2014
Messages
4,459
I understand their usage but have never used TempVars and macros in my dbs. So I don't have sample. I have seen tutorials that demonstrate. Do research and should find.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:56
Joined
May 7, 2009
Messages
16,826
here is the macro adding Tempvars.
 

Attachments

  • 17.accdb
    1.1 MB · Views: 163

Sarah.M

Member
Local time
Today, 15:56
Joined
Oct 28, 2021
Messages
303
here is the macro adding Tempvars.
Wow It works!,
but how this magic is happened can you give me some explanation? plz 🙏
how "Edit" as text change the Mode and make Tab1 disabled there?
how Tab1 become disable I did not see "False" in value section?
How "Edit" become "False" in value section? 🤯
I am surprised :oops:
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:56
Joined
May 7, 2009
Messages
16,826
the first form set the tempvar to "Add" or (if you add another button, you set it to "Edit").
the second form, catches the tempvar on the Load Event.

([TempVars]![tvarOpenMode] = "Edit") will result in either True or False, depends what is the value of tvarOpenMode.
 

Sarah.M

Member
Local time
Today, 15:56
Joined
Oct 28, 2021
Messages
303
the first form set the tempvar to "Add" or (if you add another button, you set it to "Edit").
the second form, catches the tempvar on the Load Event.

([TempVars]![tvarOpenMode] = "Edit") will result in either True or False, depends what is the value of tvarOpenMode.
I am still surprised,
1 TempVars gives 2 jobs
because, what I know Value section can take True False, Yes No, -1 0, I never read that Value can take Add as True and Edit as False 🤯

Thanks!!!
 

June7

AWF VIP
Local time
Today, 04:56
Joined
Mar 9, 2014
Messages
4,459
It is not taking Add as True and Edit as False. The equality expression is returning either True or False result. That result is setting property.
 

Sarah.M

Member
Local time
Today, 15:56
Joined
Oct 28, 2021
Messages
303
It is not taking Add as True and Edit as False. The equality expression is returning either True or False result. That result is setting property.
For example ([TempVars]![tvarOpenMode] = "Blue") setProperity Value ([TempVars]![tvarOpenMode] = "Red")
He will consider that Blue is True and Red is False? or it means anything written first will be considered as True? How does MS Access knows that "add" means True?
This topic is interesting to me kindly explain more to me plz 🙏
 

June7

AWF VIP
Local time
Today, 04:56
Joined
Mar 9, 2014
Messages
4,459
The TempVars!tvarOpenMode is set to either "Add" or "Edit" in button click. Then used in equality expression ([TempVars]![tvarOpenMode] = "Edit"). That expression calculates to either True or False. If the TempVar has been set to "Add" then the result is False because "Add" does not = "Edit". If TempVar has been set to "Edit" then the result is True because "Edit" is = to "Edit".
 

Sarah.M

Member
Local time
Today, 15:56
Joined
Oct 28, 2021
Messages
303
The TempVars!tvarOpenMode is set to either "Add" or "Edit" in button click. Then used in equality expression ([TempVars]![tvarOpenMode] = "Edit"). That expression calculates to either True or False. If the TempVar has been set to "Add" then the result is False because "Add" does not = "Edit". If TempVar has been set to "Edit" then the result is True because "Edit" is = to "Edit".
Thanks for the clarification!!!
 

Users who are viewing this thread

Top Bottom