G
Guest
My users prefer to see a list of some 60 [Services] check boxes rather than
use a subform of combo boxes with the same list of [Services] (my
preference). This makes creating search forms very cumbersome and requiring
many queries and isn't very updatable. I wrote some code to add the record Id
and a Service Id (from a table) to a join table, like so:
Select Case chk.Name
Case "chkDD"
idServ = 1
Case "chkEdu"
idServ = 2
Case "chkHousing"
idServ = 3
etc.
If chk = True Then ' Update tbl_ServiceProvided if box checked.
Set rs = tbl.OpenRecordset
With rs
.AddNew
!ResourceId = Forms!RESOURCE!ResourceId
!ServiceId = idServ
.Update
End With
rs.Close
End If
If chk = False Then ' Delete any record created by above If
statement if box unchecked.
Set rs = tbl.OpenRecordset
If rs!ResourceId = Forms!RESOURCE!ResourceId And rs!ServiceId =
idServ Then
rs.Delete
End If
rs.Close
End If
However, this creates substantial complexity in the data entry form, namely,
new records must be saved before the Service checks can be used. So I put
them on a subform and put a Save macro on the subforms OnCurrent, but this
slows down browsing whenever I apply or remove a filter - not to mention I
can't filter the subform checks like I could when they were all on the same
form.
One solution: put code on the Before Update of all the checks that somehow
checks whether the record has been saved, then either saves on its own or
prompts the user to save?
use a subform of combo boxes with the same list of [Services] (my
preference). This makes creating search forms very cumbersome and requiring
many queries and isn't very updatable. I wrote some code to add the record Id
and a Service Id (from a table) to a join table, like so:
Select Case chk.Name
Case "chkDD"
idServ = 1
Case "chkEdu"
idServ = 2
Case "chkHousing"
idServ = 3
etc.
If chk = True Then ' Update tbl_ServiceProvided if box checked.
Set rs = tbl.OpenRecordset
With rs
.AddNew
!ResourceId = Forms!RESOURCE!ResourceId
!ServiceId = idServ
.Update
End With
rs.Close
End If
If chk = False Then ' Delete any record created by above If
statement if box unchecked.
Set rs = tbl.OpenRecordset
If rs!ResourceId = Forms!RESOURCE!ResourceId And rs!ServiceId =
idServ Then
rs.Delete
End If
rs.Close
End If
However, this creates substantial complexity in the data entry form, namely,
new records must be saved before the Service checks can be used. So I put
them on a subform and put a Save macro on the subforms OnCurrent, but this
slows down browsing whenever I apply or remove a filter - not to mention I
can't filter the subform checks like I could when they were all on the same
form.
One solution: put code on the Before Update of all the checks that somehow
checks whether the record has been saved, then either saves on its own or
prompts the user to save?