Group checkboxes on subform

  • Thread starter Thread starter Yara
  • Start date Start date
Y

Yara

Hello,

I am creating a form that has two fields on it that are linked to a table.
When I click one of the fields a subform opens. On this subform I have
created a group of 9 checkboxes (like a matrix). If the first checkbox is
checked, I want the value "T" to be entered in the first field of the
mainform and the value "W" to be entered in the second field of the mainform
then the subform should close. If the secondbox is checked then different
values should be entered in the feld and so on.

I suspect that I need to write a procedure in the propertiesfield on key
press of the first checkbox and do the same with the other checkboxes. But I
don't know the code. Can anyone help me? The name of the mainform =
FrmOverzicht, the name of field 1 on the mainform = info and field 2 = NNW.

Thanks in advance,
Yara
 
You can put code like this on the after update of the checkbox.

Private Sub Check1_AfterUpdate
If Me.Check1 = True Then
Me.Parent.[NameOfControlA] = "T"
Me.Parent.[NameOfControlB] = "W"
DoCmd.Close acForm, Me.Name
End If
End Sub


The above code assumes that the first checkbox is called Check1
Where the code has [NameOfControlA] , replace it with the name of the
control on the main form.
Do similar for [NameOfControlB]

Do a similar thing for the other 8 checkboxes.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Hi Jeanette,

Thank you for the code. It works fine with checkboxes. Is there anyway I can
use this on a selection button (Sorry I have the Dutch version and I don't
know the english name for this). There is no after update there. Where can I
put it then. I have tried to place the code at key press but that doen't
work. Can you plese help me again?

Kind regards,
Yara

Jeanette Cunningham said:
You can put code like this on the after update of the checkbox.

Private Sub Check1_AfterUpdate
If Me.Check1 = True Then
Me.Parent.[NameOfControlA] = "T"
Me.Parent.[NameOfControlB] = "W"
DoCmd.Close acForm, Me.Name
End If
End Sub


The above code assumes that the first checkbox is called Check1
Where the code has [NameOfControlA] , replace it with the name of the
control on the main form.
Do similar for [NameOfControlB]

Do a similar thing for the other 8 checkboxes.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

Yara said:
Hello,

I am creating a form that has two fields on it that are linked to a table.
When I click one of the fields a subform opens. On this subform I have
created a group of 9 checkboxes (like a matrix). If the first checkbox is
checked, I want the value "T" to be entered in the first field of the
mainform and the value "W" to be entered in the second field of the
mainform
then the subform should close. If the secondbox is checked then different
values should be entered in the feld and so on.

I suspect that I need to write a procedure in the propertiesfield on key
press of the first checkbox and do the same with the other checkboxes. But
I
don't know the code. Can anyone help me? The name of the mainform =
FrmOverzicht, the name of field 1 on the mainform = info and field 2 =
NNW.

Thanks in advance,
Yara


.
 
In addition to my respons earlier: I noticed that when I use a group of
selection buttons there is no after update in the properties but when I use
just 1 selection button it does have after update. Same goes for checkboxes;
as soon as I put them in a group it loses the option for after update in the
properties.
I will use the buttons alone instead of grouped.

Thanks again for the help.

Regards,
Yara

Jeanette Cunningham said:
You can put code like this on the after update of the checkbox.

Private Sub Check1_AfterUpdate
If Me.Check1 = True Then
Me.Parent.[NameOfControlA] = "T"
Me.Parent.[NameOfControlB] = "W"
DoCmd.Close acForm, Me.Name
End If
End Sub


The above code assumes that the first checkbox is called Check1
Where the code has [NameOfControlA] , replace it with the name of the
control on the main form.
Do similar for [NameOfControlB]

Do a similar thing for the other 8 checkboxes.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

Yara said:
Hello,

I am creating a form that has two fields on it that are linked to a table.
When I click one of the fields a subform opens. On this subform I have
created a group of 9 checkboxes (like a matrix). If the first checkbox is
checked, I want the value "T" to be entered in the first field of the
mainform and the value "W" to be entered in the second field of the
mainform
then the subform should close. If the secondbox is checked then different
values should be entered in the feld and so on.

I suspect that I need to write a procedure in the propertiesfield on key
press of the first checkbox and do the same with the other checkboxes. But
I
don't know the code. Can anyone help me? The name of the mainform =
FrmOverzicht, the name of field 1 on the mainform = info and field 2 =
NNW.

Thanks in advance,
Yara


.
 
When you use the 'selection button' - we call it an option group or frame.
Instead of using the after update for each check box or each button,
use the value for the option group.

If I have an option group with 3 checkboxes or selection buttons,
When I check the first checkbox, the option group will have the value =1.
When I check the second checkbox, the option group will have the value = 2.
Similar for the third checkbox ( assuming that check = show tick).

So your code uses the value of the option group (frame), instead of looking
for the value for each checkbox or button inside the frame.

If Not Is Null (Me.NameOfOptionGroup) Then
Select Case Me.NameOfOptionGroup
Case 1
'code to do something

Case 2
'code to do something

Case 3
'code to do something

End Select



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Yara said:
In addition to my respons earlier: I noticed that when I use a group of
selection buttons there is no after update in the properties but when I
use
just 1 selection button it does have after update. Same goes for
checkboxes;
as soon as I put them in a group it loses the option for after update in
the
properties.
I will use the buttons alone instead of grouped.

Thanks again for the help.

Regards,
Yara

Jeanette Cunningham said:
You can put code like this on the after update of the checkbox.

Private Sub Check1_AfterUpdate
If Me.Check1 = True Then
Me.Parent.[NameOfControlA] = "T"
Me.Parent.[NameOfControlB] = "W"
DoCmd.Close acForm, Me.Name
End If
End Sub


The above code assumes that the first checkbox is called Check1
Where the code has [NameOfControlA] , replace it with the name of the
control on the main form.
Do similar for [NameOfControlB]

Do a similar thing for the other 8 checkboxes.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

Yara said:
Hello,

I am creating a form that has two fields on it that are linked to a
table.
When I click one of the fields a subform opens. On this subform I have
created a group of 9 checkboxes (like a matrix). If the first checkbox
is
checked, I want the value "T" to be entered in the first field of the
mainform and the value "W" to be entered in the second field of the
mainform
then the subform should close. If the secondbox is checked then
different
values should be entered in the feld and so on.

I suspect that I need to write a procedure in the propertiesfield on
key
press of the first checkbox and do the same with the other checkboxes.
But
I
don't know the code. Can anyone help me? The name of the mainform =
FrmOverzicht, the name of field 1 on the mainform = info and field 2 =
NNW.

Thanks in advance,
Yara


.
 
Thanks Jeanette,

It works excellent! This is fun I keep learning things.
Thanks again!
Kind regards,
Yara

Jeanette Cunningham said:
When you use the 'selection button' - we call it an option group or frame.
Instead of using the after update for each check box or each button,
use the value for the option group.

If I have an option group with 3 checkboxes or selection buttons,
When I check the first checkbox, the option group will have the value =1.
When I check the second checkbox, the option group will have the value = 2.
Similar for the third checkbox ( assuming that check = show tick).

So your code uses the value of the option group (frame), instead of looking
for the value for each checkbox or button inside the frame.

If Not Is Null (Me.NameOfOptionGroup) Then
Select Case Me.NameOfOptionGroup
Case 1
'code to do something

Case 2
'code to do something

Case 3
'code to do something

End Select



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Yara said:
In addition to my respons earlier: I noticed that when I use a group of
selection buttons there is no after update in the properties but when I
use
just 1 selection button it does have after update. Same goes for
checkboxes;
as soon as I put them in a group it loses the option for after update in
the
properties.
I will use the buttons alone instead of grouped.

Thanks again for the help.

Regards,
Yara

Jeanette Cunningham said:
You can put code like this on the after update of the checkbox.

Private Sub Check1_AfterUpdate
If Me.Check1 = True Then
Me.Parent.[NameOfControlA] = "T"
Me.Parent.[NameOfControlB] = "W"
DoCmd.Close acForm, Me.Name
End If
End Sub


The above code assumes that the first checkbox is called Check1
Where the code has [NameOfControlA] , replace it with the name of the
control on the main form.
Do similar for [NameOfControlB]

Do a similar thing for the other 8 checkboxes.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

Hello,

I am creating a form that has two fields on it that are linked to a
table.
When I click one of the fields a subform opens. On this subform I have
created a group of 9 checkboxes (like a matrix). If the first checkbox
is
checked, I want the value "T" to be entered in the first field of the
mainform and the value "W" to be entered in the second field of the
mainform
then the subform should close. If the secondbox is checked then
different
values should be entered in the feld and so on.

I suspect that I need to write a procedure in the propertiesfield on
key
press of the first checkbox and do the same with the other checkboxes.
But
I
don't know the code. Can anyone help me? The name of the mainform =
FrmOverzicht, the name of field 1 on the mainform = info and field 2 =
NNW.

Thanks in advance,
Yara


.


.
 
Back
Top