Checkboxes not greyed out

Steven

Registered User.
Local time
Today, 13:47
Joined
Mar 5, 2011
Messages
15
Hello All,

I have a subform with checkboxes, if I click one then the others are greyed out, this works fine, but when I close my form and open it again, then it shows all the check boxes again, they are not greyed out anymore.
What code do I need to leave them greyed out.

Thx in advance for your replies and time,
Steven.
 
Are your check boxes are bound to any field in your database? the field should have the Yes / No data type property to store the check box data in the table.
 
Hello Khalid,

Thx for your reply.
My checkboxes are attached to a column in a table.

Greetings,
Steven.
 
This mean that you are also storing data in a table bound to the check boxes. If you want to store the check box to be checked for every new record, then change the default value of the check box to 1 in the table structure Or on your form under the default value property.

0 is the unchecked default value of the checkbox
 
Hello Khalid,

Thx again for your reply, but what I mean is:
Someone fills in my form and subform
On the subform Question 1 contains checkbox A, B, C and D.
If he chooses A then the others B, C and D are greyed out and if he unchecks A then all are normal again and can be choosed.
This works fine in my form.

Now he closes the database or the form and reopens it. He then chooses the product on the form and on the subform he sees that box A is checked, but the other boxes are not greyed out any more.
What I need is, how the form searches when reopend again, which of the 4 boxes is checked and then greyes out the others again.

Hope this is more clearly explained.

Greetings,
Steven.
 
Hi Steven,
Your
If he chooses A then the others B, C and D are greyed out and if he unchecks A then all are normal again and can be choosed.
seems that you are using Radio Buttons or Option Buttons where one option is checked and then others are qray out?
can you please attach your db so that i would be able to solve it as per your request.
Thanks
 
Hi Khalid,

Here is the database. Just open Frm Projecten. And look in the subform that is also opened. Fill in the main form and then play around with the subform. You see that all the checkboxes are working and greyed out. Now when you have filled in some of the fields and then close the database. Then reopen it and also the form. Then you will see that there is no greyed out anymore. So it doesn't store these functionality. Question is, how to keep this when the form is opened again.

Many thx for your time and effort,
Steven.
 

Attachments

Hi Khalid,

Here is the database. Just open Frm Projecten. And look in the subform that is also opened. Fill in the main form and then play around with the subform. You see that all the checkboxes are working and greyed out. Now when you have filled in some of the fields and then close the database. Then reopen it and also the form. Then you will see that there is no greyed out anymore. So it doesn't store these functionality. Question is, how to keep this when the form is opened again.

Many thx for your time and effort,
Steven.

Steven, I study your database and add some code on the subform current event.
Please check it out and include it to your "Frm Vragenlijst" form.
Code:
Private Sub Form_Current()
'==========================
If BodemGoed = True Then
    'Als de BodemGoed JA is dan NIET invoer andere van 14.
    BodemSlecht.Enabled = False
    BodemNormaal.Enabled = False
Else
    BodemSlecht.Enabled = True
    BodemNormaal.Enabled = True
End If
'==========================
If BodemNormaal = True Then
    'Als de BodemNormaal JA is dan NIET invoer andere van 14.
    BodemSlecht.Enabled = False
    BodemGoed.Enabled = False
Else
    BodemSlecht.Enabled = True
    BodemGoed.Enabled = True
End If
'============================
If BodemSlecht = True Then
    'Als de BodemSlecht JA is dan NIET invoer andere van 14.
    BodemNormaal.Enabled = False
    BodemGoed.Enabled = False
Else
    BodemNormaal.Enabled = True
    BodemGoed.Enabled = True
End If
'==============================
If HistorischGebied = True Then
    'Als de HistorischGebied JA is dan NIET invoer andere van 3.
    BinnenstedelijkeLocatie.Enabled = False
    InbreidingsLocatie.Enabled = False
    UitlegLocatie.Enabled = False
'Else
'    BinnenstedelijkeLocatie.Enabled = True
'    InbreidingsLocatie.Enabled = True
'    UitlegLocatie.Enabled = True
End If
'================================
If BinnenstedelijkeLocatie = True Then
    'Als de BinnenstedelijkeLocatie JA is dan NIET invoer andere van 3.
    HistorischGebied.Enabled = False
    InbreidingsLocatie.Enabled = False
    UitlegLocatie.Enabled = False
'Else
'    HistorischGebied.Enabled = True
'    InbreidingsLocatie.Enabled = True
'    UitlegLocatie.Enabled = True
End If
'=============================
If InbreidingsLocatie = True Then
    'Als de InbreidingsLocatie JA is dan NIET invoer andere van 3.
    HistorischGebied.Enabled = False
    BinnenstedelijkeLocatie.Enabled = False
    UitlegLocatie.Enabled = False
'Else
'    HistorischGebied.Enabled = True
'    BinnenstedelijkeLocatie.Enabled = True
'    UitlegLocatie.Enabled = True
End If
'=================================
If Projectafwijkingsbesluit = True Then
    'Als het Projectafwijkingsbesluit JA is dan NIET invoer andere van 11.
    HoeveelUitwerkingsplannen.Enabled = True
    GedetailleerdBestemmingsplan.Enabled = False
    'Als 11 is ingevuld dan vraag 12 niet kunnen invullen
    GebruikWijzigingBestemmingsplan.Enabled = False
'Else
'    HoeveelUitwerkingsplannen.Enabled = False
'    GedetailleerdBestemmingsplan.Enabled = True
'    GebruikWijzigingBestemmingsplan.Enabled = True
End If
'================================
If GedetailleerdBestemmingsplan = True Then
    'Als het GedetailleerdBestemmingsplan JA is dan NIET invoer andere van 11.
    Projectafwijkingsbesluit.Enabled = False
    HoeveelUitwerkingsplannen.Enabled = False
    'Als 11 is ingevuld dan vraag 12 niet kunnen invullen
    GebruikWijzigingBestemmingsplan.Enabled = False
'Else
'    Projectafwijkingsbesluit.Enabled = True
'    HoeveelUitwerkingsplannen.Enabled = False
'    GebruikWijzigingBestemmingsplan.Enabled = True
End If
'==================================
If GebruikWijzigingBestemmingsplan = True Then
    'Als het GebruikWijzigingBestemmingsplan JA is dan NIET invoer van 11.
    Projectafwijkingsbesluit.Enabled = False
    GedetailleerdBestemmingsplan.Enabled = False
'Else
'    Projectafwijkingsbesluit.Enabled = True
'    GedetailleerdBestemmingsplan.Enabled = True
End If
'==================================
If UitlegLocatie = True Then
    'Als de UitlegLocatie JA is dan NIET invoer andere van 3.
    HistorischGebied.Enabled = False
    BinnenstedelijkeLocatie.Enabled = False
    InbreidingsLocatie.Enabled = False
'Else
'    HistorischGebied.Enabled = True
'    BinnenstedelijkeLocatie.Enabled = True
'    InbreidingsLocatie.Enabled = True
End If
'================================
If OphogingOfVoorbelasting = True Then
    'Als de OphogingOfVoorbelasting JA is dan WEL invoer 16a t/m d.
    Keuzelijst164.Enabled = True
    DeelplanFase.Enabled = True
    Zettingstijd.Enabled = True
    HoogteVoorbelasting.Enabled = True
    'Beweeg de cursor naar OphogingIntegraal.
    Keuzelijst164.SetFocus
'Else
'    'Als de OphogingOfVoorbelasting NEE is dan NIET invoer 16a t/m d.
'    Keuzelijst164.Enabled = False
'    DeelplanFase.Enabled = False
'    Zettingstijd.Enabled = False
'    HoogteVoorbelasting.Enabled = False
End If

End Sub

It will work exactly what you want.
One thing I will mention here that seeing your Database, I found so may bad normalization practice, FieldNames rules, and having too many fields in one table, I can see 48 fields in one table with very very long Field's name.
attachment.php

Please remember that as a good database developer, you should avoid a very long field name, also a table should not have too many fields in it. Good Normalization and integration of data plays very much important rule in database. If you have a very long Fieldname, then its very difficult to call these name while programming and calling them in query.
This effect the performance of the Application resulting slow execution.

attachment.php


I am attaching your database back, you can download it and see the codes.
Please note that I have Access 2010 with accdb format which might not be opened in Access 2007, anyhow you can copy the code and paste it in your database.


Good Luck!
 

Attachments

  • Gemeente.zip
    Gemeente.zip
    137.5 KB · Views: 104
  • Relationship.jpg
    Relationship.jpg
    58 KB · Views: 758
  • Vragenlijst.jpg
    Vragenlijst.jpg
    76.1 KB · Views: 669
Hi Khalid,

Thx for your reply.
Tomorrow I will look at the code, it is too late now.
About your comments, I now some have a lot of columns, but this meant to be.
The forms are just questions to be answered, every enty in the forms are needed for calculations and the final results will be saved in proper tables. The long names will be shortened, these are just for some showing purposes to people that do not understand how databases work.

Thx again for your time, I let you know if everything works.
Steven.
 
Hi Khalid,

It worked good, the only thing I needed to do was to unquote the ELSE statements, because else the next record on the form has the same greyed out boxes as the last one that has been filled in and that is not as mented, because the new subform record get a standard with some things greyed out.

Many thx again for your time and help,
Steven.
 
Hi Khalid,

It still isn't working good. Because if you go to the next record on the main form, you see that the subform holds the choices of the previous record. But it must be refreshed everytime you go to a new or already existing record on the main form.

Greetings,
Steven.
 
Hi Khalid,

It still isn't working good. Because if you go to the next record on the main form, you see that the subform holds the choices of the previous record. But it must be refreshed everytime you go to a new or already existing record on the main form.

Greetings,
Steven.

Steven!
I have commented your codes purposely for that reasons only, because in your case if you uncomment the code where it is not necessary, it again enable the checkboxes in the on current event.

To check which condition to be true on form current event, just put the break points in your form current event code. Break points can be easily put on exicutable lines anywhere in the code. Just click on the left right most vertical Bar of the code or put your cursor on the line where you want to put the break points and goto Menu>>>>Debug>>>>Toggle Breakpoint... from the menu bar in code window, a dark red point will appear on the left bar, now open your form and you will see the code window with yellow highlighted color indicating your current line of code, just press F8 to toggle the line, closely monitor and examine your code and apply or remove the comments where applicable.

Hope this would help.

Regards,
 

Users who are viewing this thread

Back
Top Bottom