I form that contains a subform that lists multiple records as a datasheet. In the subform is a checkbox type column called "Select". (control name is chk_select).
This column is used to select which records they would like to open in a separate form. After checking which records they would like to open by checking the checkboxes, a button then opens a separate detail form to the records where the "Select" column = True.
My issues is that unless the focus is on a line in the datasheet where the checkbox is selected, Access can't open the detail form.
For example, I would check the box to select the record I wanted to open, then click on a different line where the checkbox is not selected, and try to open the detail form but Access doesn't seem to see that there are records selected. But if I move the cursor to any line where the checkbox is checked, then the detail form opens just fine for all the records where the checkbox is selected.
My current workaround is to display a message box to try and get the user to move the cursor to a line where the checkbox is selected. But I'd like to have this done automatically before opening the other form to avoid any confusion for the user.
So I need a way to use SetFocus to a subform control where the checkbox = True before opening the detail form.
Is there any way to do this or a workaround?
Here is what I have so far.
Thank you.
Private Sub btn_open_estimate2_Click()
If Forms![View Estimates]![TblEstimates subform]![chk_select] = True Then
'Forms![View Estimates]![TblEstimates subform]![chk_select].SetFocus ***Need something similar to Where [chk_select]=True
DoCmd.OpenForm "Edit Estimate", , , "TblEstimates.select = True"
DoCmd.Close acForm, "View Estimates", acSaveYes
Else
MsgBox "Please select an Estimate to open, or " & _
"move the cursor to a selected Estimate to be able to open it", VbMsgBoxStyle.vbExclamation, "No Estimate Selected"
End If
End Sub