Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Flag for Zambia asked on

How to code a checkbox in VBA Ms Access

Dear Experts
I still need your expert guidance on the issue below:
(1)      I have form bound to customer table, the type of customers we have range from students, trading customers, hotels or tourist & patients. Since the only difference is in terms of data capturing and the nature of customers in question.

So, we want the same form to be used to across the board BUT with option to select the type of data applicable, for example see below:
•      Company (This may be used for general trading)
•      StudentName (This could be for schools)
•      TouristName (this could be for hotels)
The above three controls must be made optional with a check box so that only customers applicable in that business must be VISIBLE if they are NOT checked.
Question
With the use of VBA how do I use a check box to hide those controls that are not required to be updated depending to the business nature AND unhide after update. The issue here is how to code the checkbox (Option39) vs control name (studentName) etc, for example something in this line.
Example:
Afterupdate option39()
Me.StudentName .Visible = False
Exist Sub
End If

Open in new window


The advantage of the suggested system will save us from creating independent tables per each business category. The good news here is that even if I’m sitting at 120 tables, 350 queries, 1 macro & 120 Modules, no single object failed the MS access performance analyser test. If you look at the actual application performance you might think that it has only 4 tables and a few queries, its extremely fast. The application covers the following:

(1)      Schools
(2)      Tourism
(3)      General trading
(4)      Retail trading
(5)      Hospitals and
(6)      insurance
Customers-maintenance.png
Microsoft AccessVBA

Avatar of undefined
Last Comment
Neil Fleming

8/22/2022 - Mon
ste5an

The normal solution; Use sub-forms for the different sub-classes of your customers. Just load the necessary sub-form, when the main form is loaded.

The advantage of the suggested system will save us from creating independent tables per each business category.
There is a 99% chance, that this is not a correctly normalized data model.

The model here to chose is the super-sub-class model. You have one main table, which has the common column for all classes and an additional column as discriminator, which marks the class type.

Each sub-class, which has columns, which are not part of the common columns requires a depended table (FK by using the ID and the discriminator column) to store the per class type information.

For each of those sub-classes you create one sub-form, which is then loaded into the main form.
ASKER CERTIFIED SOLUTION
Dale Fye

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Neil Fleming

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61