If Forms contol textbox contains "LBBT" - then Show command button

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,486
I work only occasionally with Access. But on one of my forms, if the user (from a Combo Box) selects ONLY "LBBT",
(There are 5 or 6 choices - 1 of which is LBBT) what code and how would I suddenly show a clickable command button to once I click it - it opens an existing table for further data entry against the LBBT choice?

Thanks, Jim
 
Last edited:

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
On form Open, set the button visible property to False. Should code fail after you have shown the button and you save the form, the property can get set to True, which would make it visible next time you open the form. On AfterUpdate, get the cmbMyCombo.ItemsSelected.Count. If >1 don't execute the rest of an If block since your trigger value cannot be the only value selected. If it is >1 execute the rest of the If block and loop through the itemselected values to find (in a nested IF) if your trigger value is one of these. If it is, make your button visible (me.cmdButn.visible = true). The click event for the button should open a select query, NOT expose the entire table. Plus, a query will allow you to filter the recordset to whatever is related to your value. If you need help with code, post what you have for this.
 
Upvote 0
Thanks Micron... I have a Standard Module with a number of procedures. Is there Code modules "behind" Forms, or is it rather Code windows behind the Form's Controls? Jim
 
Upvote 0
Modules 101: A standard module is one of two types whose code can be accessed from anywhere in the project. A class module (the other) is used to create a custom object that has properties and (I think) methods as well. A form or report module exists "behind" a form/report and its code is not visible outside of the form/report. Any code (sub) specific to a control event (textbox, command button, etc) resides within the form/report module, but its scope is limited to the sub. However, you can affect variables outside of the sub by declaring them in the declarations section of the module (at the very top). This effect is true of any module. Hope that helps.
 
Upvote 0
I made 2 assumptions in my first post. 1) that you have a newer Access version (me, 2007) that allows a multi-select combobox and that 2) it would have similar properties to a list box. I suspect you are dealing with what MS calls a "checkbox list": https://support.office.com/en-za/ar...e-values-c8d15127-3641-45fc-aa2d-a3943d355e89. After researching a bit more, I find that Access still does not have a multi-select combo box. So if it is a checkbox list, I have no experience and can't help with that. If you decide to change the control to a listbox, I can.
 
Upvote 0
Micron, thanks for your input to date. I have progressed to the point of writing the code (Events - Both Form.Current and cboControlname.AfterUpdate) so that My Command button is visible and invisible properly.
I have also created a table and an identical query AND a form built on the Query to enter data related ONLY to any "LDDT" entries. The PrimaryKey in my Main Form is "NonID", the PrimaryKey in my new form is also "NonID". So the relationship between the two is very much like a form/subform. Is there a way I can "link" these objects in a simple way, or should I go thru establishing a formal MasterForm/SubForm situation?
 
Upvote 0
My approach would be the form/subform if you need to keep both open at the same time - especially if your forms are in separate windows and not tabs. Having to flip between one or the other in separate windows or tabs just seems not user friendly to me. Plus, it would be more difficult to maintain a parent-child relationship between separate forms. At least, more difficult than it needs to be. If you're going to close the first and open the second for input, I suppose it's a matter of preference. One approach that your situation reminds me of is but I have never wanted to replicate is a popup input box that was the only way to make field edits.
 
Upvote 0

Forum statistics

Threads
1,221,849
Messages
6,162,425
Members
451,765
Latest member
craigvan888

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top