How to make Selections in a form invoke Checkboxes in Parent Form

Y

Yaw Addo

I have a simple database consisting of a Main Table with a one-to-many
relationship with another table. The Main form is displayed as a single form
and the other as a continuous form. The Main form (one) contains details of a
building and the other contains individual details(many) of each Utility to
the linked building.
I have tried code to run a query and use the If, Then else statements to
invoke check boxes but it only addresses the first option out of 8 and
ignores the rest. Any advise? See code below:

Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Dim rstUtil As DAO.Recordset
Dim fldUtil As Field

Set dbs = CurrentDb
Set qdfs = dbs.OpenRecordset("Q_IDApplicableUtilities")
strSQL = "SELECT T_Utility.[Utility Desc] FROM T_Utility WHERE
(((T_Utility.BldgLink)=[Forms]![F_OPZbldgs]![ID]));"

Set qdf = dbs.CreateQueryDef("", strSQL)
Set rstUtil = dbs.OpenRecordset("T_Utility", dbOpenTable)
' this gives an error: 'Set rstUtil =
dbs.OpenRecordset("Q_IDApplicableUtilities", dbOpenTable)
Set fldUtil = rstUtil.Fields("Utility_Desc")


For Each fldUtil In rstUtil.Fields
If rstUtil![Utility_Desc] = 1 Then
Me![CheckPWATER] = 1
MsgBox "Potable Water Connection Exists to This Building"
Else: Me![CheckPWATER] = False

Exit For
End If
Next fldUtil
'plan is to repeat this for all the other Utility Types
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top