![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, I was wondering what the most efficient way of capturing check box values from those records in a form which are checked so that I can use the values in code. I have a form with 5 controls, 1 is a checkbox. The user will check the records he wants chosen and then click a CommandButton. In the commandButton code I want to be able to display the selected control values like this: Dim Control4 as String Control4 = "SelectedRec1Value,SelectedRec2Value,SelectedRec3V alue,SelectedRec4Value" etc Any assistance Much appreciated Tahnk you Regards Kevin |
#3
| |||
| |||
|
|
Kev wrote: Hello, I was wondering what the most efficient way of capturing check box values from those records in a form which are checked so that I can use the values in code. I have a form with 5 controls, 1 is a checkbox. The user will check the records he wants chosen and then click a CommandButton. In the commandButton code I want to be able to display the selected control values like this: Dim Control4 as String Control4 = "SelectedRec1Value,SelectedRec2Value,SelectedRec3V alue,SelectedRec4Value" etc Any assistance Much appreciated Tahnk you Regards Kevin Public Function ListCheckBoxes(frm As Form) As String * * *'get the names of checkboxes on a form and the value * * *Dim ctl As Control * * *Dim s As String * * *For Each ctl In frm.Controls * * * * *If ctl.ControlType = acCheckBox Then * * * * * * *s = s & ctl.Name & " " & NZ(ctl.Value, 0) & "," * * * * *End If * * *Next * * *ListCheckBoxes = s End Function I called it from the form. *Ex: * * *Private Sub Command`_Click() * * * * MsgBox ListCheckBoxes(Me) * * *End Sub It simply lists the checkbox name and their values. *Modify to suit. |
#4
| |||
| |||
|
|
Thanks for this Salad, I'm not sure if I have applied your code correctly or explained my issue sufficiently. It only seems to be listing one checkbox. I have seen where I need to expand my explaination: I want to capture the value of another control (say Cont4) when Cont1 = Yes, Cont1 being the checkbox: Cont1 Cont2 Cont3 Cont4 Cont5 Record1 Yes abc 1623 fred 5456 Record2 No xabc 1823 bill 4526 Record3 Yes aybc 7123 mike 4h56 Record4 No abzc 9123 peter 4h56 Record5 Yes abcw 5123 jerry 4g56 Result of variable would give me: variable1 = "fred, mike, jerry" I wish to then use this variable in future code. Apologies re confusion of explaination Regards Kevin On Aug 9, 1:59 pm, Salad <sa... (AT) oilandvinegar (DOT) com> wrote: Kev wrote: Hello, I was wondering what the most efficient way of capturing check box values from those records in a form which are checked so that I can use the values in code. I have a form with 5 controls, 1 is a checkbox. The user will check the records he wants chosen and then click a CommandButton. In the commandButton code I want to be able to display the selected control values like this: Dim Control4 as String Control4 = "SelectedRec1Value,SelectedRec2Value,SelectedRec3V alue,SelectedRec4Value" etc Any assistance Much appreciated Tahnk you Regards Kevin Public Function ListCheckBoxes(frm As Form) As String 'get the names of checkboxes on a form and the value Dim ctl As Control Dim s As String For Each ctl In frm.Controls If ctl.ControlType = acCheckBox Then s = s & ctl.Name & " " & NZ(ctl.Value, 0) & "," End If Next ListCheckBoxes = s End Function I called it from the form. Ex: Private Sub Command`_Click() MsgBox ListCheckBoxes(Me) End Sub It simply lists the checkbox name and their values. Modify to suit. |
#5
| |||
| |||
|
|
Thanks for this Salad, I'm not sure if I have applied your code correctly or explained my issue sufficiently. It only seems to be listing one checkbox. I have seen where I need to expand my explaination: I want to capture the value of another control (say Cont4) when Cont1 = Yes, Cont1 being the checkbox: Cont1 Cont2 Cont3 Cont4 Cont5 Record1 Yes abc 1623 fred 5456 Record2 No xabc 1823 bill 4526 Record3 Yes aybc 7123 mike 4h56 Record4 No abzc 9123 peter 4h56 Record5 Yes abcw 5123 jerry 4g56 Result of variable would give me: variable1 = "fred, mike, jerry" I wish to then use this variable in future code. Apologies re confusion of explaination Regards Kevin On Aug 9, 1:59 pm, Salad <sa... (AT) oilandvinegar (DOT) com> wrote: Kev wrote: Hello, I was wondering what the most efficient way of capturing check box values from those records in a form which are checked so that I can use the values in code. I have a form with 5 controls, 1 is a checkbox. The user will check the records he wants chosen and then click a CommandButton. In the commandButton code I want to be able to display the selected control values like this: Dim Control4 as String Control4 = "SelectedRec1Value,SelectedRec2Value,SelectedRec3V alue,SelectedRec4Value" etc Any assistance Much appreciated Tahnk you Regards Kevin Public Function ListCheckBoxes(frm As Form) As String 'get the names of checkboxes on a form and the value Dim ctl As Control Dim s As String For Each ctl In frm.Controls If ctl.ControlType = acCheckBox Then s = s & ctl.Name & " " & NZ(ctl.Value, 0) & "," End If Next ListCheckBoxes = s End Function I called it from the form. Ex: Private Sub Command`_Click() MsgBox ListCheckBoxes(Me) End Sub It simply lists the checkbox name and their values. Modify to suit. |
![]() |
| Thread Tools | |
| Display Modes | |
| |