B
bymarce
Hi,
I have two tables called Data and tblStandards. Each has an autonumber
primary key called ID. They are joined through a table called
tblDataStandardsJoin with fields DataID and StandardID. My users enter
experimental data for samples in to the data table. Samples in the data
table that match for Property, Method, and DateAssigned fields would also
have the same standards. I have a button for the user to click that I want
to add reords to tblDataStandardsJoin to associate all the standardIDs of the
current DataID with other DataIDs for matching Property, Method, and
DateAssigned. Here is the code I have so far. Can this be done with an
update query or do I need to write a couple nested loops to get all
combinations of DataID and StandardID? The sql statement here returns all
the records with matching Property, Method, and DateAssigned and shows
StandardID and DataID from the join table if it exsists. I hope this is
clear. Thanks for the help!!
Marcie
Dim IDqd As QueryDef
Dim strSQL As String
Dim strQ As String
strQ = """"
Set IDqd = CurrentDb.QueryDefs("qryApplyStandards")
strSQL = "SELECT Data.[ID], Data.TestAssignedDate, Data.[Property],
Data.[TestMethod], " & _
"tblDataStandardsJoin.DataID, tblDataStandardsJoin.StandardID "
& _
"FROM Data LEFT JOIN tblDataStandardsJoin ON Data.ID =
tblDataStandardsJoin.DataID " & _
"WHERE (((Data.TestAssignedDate)=#" & Me.Parent.DateAssigned &
"#) AND ((Data.[Property]) Like " & strQ & Me.Parent.cboProperty & strQ & ")
AND " & _
"((Data.[TestMethod]) Like " & strQ & Me.Parent.cboMethod &
strQ & "));"
IDqd.sql = strSQL
IDqd.Close
DoCmd.OpenQuery "qryApplyStandards"
I have two tables called Data and tblStandards. Each has an autonumber
primary key called ID. They are joined through a table called
tblDataStandardsJoin with fields DataID and StandardID. My users enter
experimental data for samples in to the data table. Samples in the data
table that match for Property, Method, and DateAssigned fields would also
have the same standards. I have a button for the user to click that I want
to add reords to tblDataStandardsJoin to associate all the standardIDs of the
current DataID with other DataIDs for matching Property, Method, and
DateAssigned. Here is the code I have so far. Can this be done with an
update query or do I need to write a couple nested loops to get all
combinations of DataID and StandardID? The sql statement here returns all
the records with matching Property, Method, and DateAssigned and shows
StandardID and DataID from the join table if it exsists. I hope this is
clear. Thanks for the help!!
Marcie
Dim IDqd As QueryDef
Dim strSQL As String
Dim strQ As String
strQ = """"
Set IDqd = CurrentDb.QueryDefs("qryApplyStandards")
strSQL = "SELECT Data.[ID], Data.TestAssignedDate, Data.[Property],
Data.[TestMethod], " & _
"tblDataStandardsJoin.DataID, tblDataStandardsJoin.StandardID "
& _
"FROM Data LEFT JOIN tblDataStandardsJoin ON Data.ID =
tblDataStandardsJoin.DataID " & _
"WHERE (((Data.TestAssignedDate)=#" & Me.Parent.DateAssigned &
"#) AND ((Data.[Property]) Like " & strQ & Me.Parent.cboProperty & strQ & ")
AND " & _
"((Data.[TestMethod]) Like " & strQ & Me.Parent.cboMethod &
strQ & "));"
IDqd.sql = strSQL
IDqd.Close
DoCmd.OpenQuery "qryApplyStandards"