L
Little Penny
I trying to create a query that will that show me all the records in
the tbl_OperatorLogJobData that that have a value greater than 2000 in
the link table field tbl_JobGrandTotals.TotalLogEnv and have a record
count of one in the link foreign key field
tbl_PeriodicCheck.OpLogJobDataID. I receive runtime error 3079:
The specified field :OpLogJobDataID" could refer to more than one
table listed in the FROM clause of your SQL statement.
My Code:
Dim strSQL As String
Dim strWhere As String
Const conJetDate = "\#mm\/dd\/yyyy\#" 'The format expected for dates
in a JET query string.
DoCmd.OpenForm "frmSearchByQCSign", , , , , acDialog
If IsLoaded("frmSearchByQCSign") Then
strWhere = strWhere & "([tbl_JobGrandTotals.TotalLogEnv]>2000) AND "
strWhere = strWhere & "([tbl_OperatorLogJobData.InsertDate] >= " &
Format([Forms]![frmSearchByQCSign]![CboBeginningDate], conJetDate) &
") AND "
strWhere = strWhere & "([tbl_OperatorLogJobData.InsertDate] <= " &
Format([Forms]![frmSearchByQCSign]![CboEndingDate], conJetDate) & ")
AND "
strSQL = "SELECT * " & _
"FROM tbl_OperatorLogJobData " & _
"LEFT JOIN tbl_JobGrandTotals ON " & _
"tbl_OperatorLogJobData.OpLogJobDataID =
tbl_JobGrandTotals.OpLogJobDataID " & _
"WHERE " & strWhere & "OpLogJobDataID in ( " & _
"SELECT OpLogJobDataID " & _
"FROM tbl_PeriodicCheck " & _
"GROUP BY OpLogJobDataID " & _
"HAVING Count(OpLogJobDataID)=1) "
Form_frm_OperatorLogJobDataViewSQL.RecordSource = strSQL
the tbl_OperatorLogJobData that that have a value greater than 2000 in
the link table field tbl_JobGrandTotals.TotalLogEnv and have a record
count of one in the link foreign key field
tbl_PeriodicCheck.OpLogJobDataID. I receive runtime error 3079:
The specified field :OpLogJobDataID" could refer to more than one
table listed in the FROM clause of your SQL statement.
My Code:
Dim strSQL As String
Dim strWhere As String
Const conJetDate = "\#mm\/dd\/yyyy\#" 'The format expected for dates
in a JET query string.
DoCmd.OpenForm "frmSearchByQCSign", , , , , acDialog
If IsLoaded("frmSearchByQCSign") Then
strWhere = strWhere & "([tbl_JobGrandTotals.TotalLogEnv]>2000) AND "
strWhere = strWhere & "([tbl_OperatorLogJobData.InsertDate] >= " &
Format([Forms]![frmSearchByQCSign]![CboBeginningDate], conJetDate) &
") AND "
strWhere = strWhere & "([tbl_OperatorLogJobData.InsertDate] <= " &
Format([Forms]![frmSearchByQCSign]![CboEndingDate], conJetDate) & ")
AND "
strSQL = "SELECT * " & _
"FROM tbl_OperatorLogJobData " & _
"LEFT JOIN tbl_JobGrandTotals ON " & _
"tbl_OperatorLogJobData.OpLogJobDataID =
tbl_JobGrandTotals.OpLogJobDataID " & _
"WHERE " & strWhere & "OpLogJobDataID in ( " & _
"SELECT OpLogJobDataID " & _
"FROM tbl_PeriodicCheck " & _
"GROUP BY OpLogJobDataID " & _
"HAVING Count(OpLogJobDataID)=1) "
Form_frm_OperatorLogJobDataViewSQL.RecordSource = strSQL