smyleekumar
asked on
How to use an unbound checkbox for multi selection in a continuous form
Actually I have one main form when one of the button of this form is clicked it open modal continous form where i have one unbound checkbox.When this checkbox is checked i need to assign value of one of the textbox of main form to textbox of the subform.
I am able to grab the value of main form textbox value to one of the variable defined in the subform.But i am unable to do the task of assign the value of that variable to textbox of subform when unbound checkbox is checked.Here is some code which i try by creating the transparent command button named Command39 :
Public Profile_ID As Integer(Note:this is the variable which contain value of textbox of main form)
Dim colCheckbox As New Collection
Public Function IsChecked(vID As Variant) As Boolean
Dim lngID As Long
IsChecked = False
On Error GoTo exit1
lngID = colCheckbox(CStr(vID))
If lngID <> 0 Then
IsChecked = True
End If
exit1:
End Function
Private Sub Command39_Click()
On Error GoTo Err_Command39_Click
If IsChecked(Me.ProfileID) = False Then
colCheckbox.Add CLng(Me.ProfileID), CStr(Me.ProfileID)
Else
colCheckbox.Remove (CStr(Me.ProfileID))
End If
Me.chkbox_AssociatedImage. Requery
Exit_Command39_Click:
Exit Sub
Err_Command39_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command39_Click
End Sub
In above code name of checkbox is chkbox_AssociatedImage and ProfileID is name of textbox of the subform where value need to be assign when chekbox is checked.And on last thing i used control source of checkbox like this: =IsChecked([ProfileID])
SO can anybody help me by suggesting what is wrong with my aprroach.I will really happy if somebody provide me solution of my problem.
Thank you
I am able to grab the value of main form textbox value to one of the variable defined in the subform.But i am unable to do the task of assign the value of that variable to textbox of subform when unbound checkbox is checked.Here is some code which i try by creating the transparent command button named Command39 :
Public Profile_ID As Integer(Note:this is the variable which contain value of textbox of main form)
Dim colCheckbox As New Collection
Public Function IsChecked(vID As Variant) As Boolean
Dim lngID As Long
IsChecked = False
On Error GoTo exit1
lngID = colCheckbox(CStr(vID))
If lngID <> 0 Then
IsChecked = True
End If
exit1:
End Function
Private Sub Command39_Click()
On Error GoTo Err_Command39_Click
If IsChecked(Me.ProfileID) = False Then
colCheckbox.Add CLng(Me.ProfileID), CStr(Me.ProfileID)
Else
colCheckbox.Remove (CStr(Me.ProfileID))
End If
Me.chkbox_AssociatedImage.
Exit_Command39_Click:
Exit Sub
Err_Command39_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command39_Click
End Sub
In above code name of checkbox is chkbox_AssociatedImage and ProfileID is name of textbox of the subform where value need to be assign when chekbox is checked.And on last thing i used control source of checkbox like this: =IsChecked([ProfileID])
SO can anybody help me by suggesting what is wrong with my aprroach.I will really happy if somebody provide me solution of my problem.
Thank you
Attach a sample database with the issue, and instructions to follow.
You will need to use a bound checkbox. An unbound checkbox value is set for all of the continuous forms. If you don't want to add the field to the existing table, this can be done by using a transaaction table with a key to the related table and the yes/no field.
ASKER
Hi DoDahD
Can you elaborate more so it make me more clear because i m new to vba
Thank You
Can you elaborate more so it make me more clear because i m new to vba
Thank You
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.