J
javablood
I am trying to run two queries from a form (a Select and a Crosstab). Both
have a criteria ([Forms]![frm_NWBA_1]![datbegin]) in the date field that is
input from the user. For some unknown reason (as least to me) when I try to
run either both queries using OpenQuery in an event procedure or just the
crosstab query I get an error saying '[Forms]![frm_NWBA_1]![datbegin]' is
not recognized as a valid field name or expression. But this only happens
with the crosstab query, and if I hard code a date the crosstab query runs
just fine.
Alternatively, I have tried to code the SQL into a subform and use the
OpenQuery in an event procedure but then I get a Type Mismatch error from the
following:
Dim datqry As String
datqry = "TRANSFORM First(Hardage.RESULT) AS FirstOfRESULT " & _
"SELECT Hardage.PARAMETER, Hardage_PAR.F1_GRPORDR, " & _
"Hardage_Site_Identification.ID_Group, Hardage.STATION_ID " & _
"FROM Hardage_PAR INNER JOIN (Hardage_Site_Identification " & _
"INNER JOIN Hardage ON Hardage_Site_Identification.STATION_ID = " & _
"Hardage.STATION_ID) ON Hardage_PAR.PARAMETER = Hardage.PARAMETER " & _
"WHERE (((Hardage_Site_Identification.ID_Group) Like " * NWBA * ") " & _
"And ((Hardage.SAMPLE_DATE) >
Forms.frm_NWBA_1.datbegin.Form.cmddatreset) And ((Hardage.QC) = ""O"")) " & _
"GROUP BY Hardage.PARAMETER, Hardage_PAR.F1_GRPORDR,
Hardage_Site_Identification.ID_Group, " & _
"Hardage.STATION_ID ORDER BY Hardage_PAR.F1_GRPORDR PIVOT
Hardage.SAMPLE_DATE;"
DoCmd.OpenQuery "datqry", acViewDesign
Admittedly, I may have the relationship of Parent form and Subform mixed up
in Forms.frm_NWBA_1.datbegin.Form.cmddatreset (frm_NWBA_1 is Parent Form;
datbegin is control in Parent form, and cmddatreset is control in subform)
but I have even tried to just run the query from the subform using
[Forms]![frm_NWBA_2]![datx] in the query criteria for the date where datx is
input in the subform (just like 'datbegin' in the parent form) but I still
get the not recognized as a valid field name or expression error.
I am a 'learn as I go' type and the discussion group helps me to learn when
I have exhausted other resources but I have not been able to find my answer
through fourms, discussions, etc. Does anyone have an answer?
TIA!
have a criteria ([Forms]![frm_NWBA_1]![datbegin]) in the date field that is
input from the user. For some unknown reason (as least to me) when I try to
run either both queries using OpenQuery in an event procedure or just the
crosstab query I get an error saying '[Forms]![frm_NWBA_1]![datbegin]' is
not recognized as a valid field name or expression. But this only happens
with the crosstab query, and if I hard code a date the crosstab query runs
just fine.
Alternatively, I have tried to code the SQL into a subform and use the
OpenQuery in an event procedure but then I get a Type Mismatch error from the
following:
Dim datqry As String
datqry = "TRANSFORM First(Hardage.RESULT) AS FirstOfRESULT " & _
"SELECT Hardage.PARAMETER, Hardage_PAR.F1_GRPORDR, " & _
"Hardage_Site_Identification.ID_Group, Hardage.STATION_ID " & _
"FROM Hardage_PAR INNER JOIN (Hardage_Site_Identification " & _
"INNER JOIN Hardage ON Hardage_Site_Identification.STATION_ID = " & _
"Hardage.STATION_ID) ON Hardage_PAR.PARAMETER = Hardage.PARAMETER " & _
"WHERE (((Hardage_Site_Identification.ID_Group) Like " * NWBA * ") " & _
"And ((Hardage.SAMPLE_DATE) >
Forms.frm_NWBA_1.datbegin.Form.cmddatreset) And ((Hardage.QC) = ""O"")) " & _
"GROUP BY Hardage.PARAMETER, Hardage_PAR.F1_GRPORDR,
Hardage_Site_Identification.ID_Group, " & _
"Hardage.STATION_ID ORDER BY Hardage_PAR.F1_GRPORDR PIVOT
Hardage.SAMPLE_DATE;"
DoCmd.OpenQuery "datqry", acViewDesign
Admittedly, I may have the relationship of Parent form and Subform mixed up
in Forms.frm_NWBA_1.datbegin.Form.cmddatreset (frm_NWBA_1 is Parent Form;
datbegin is control in Parent form, and cmddatreset is control in subform)
but I have even tried to just run the query from the subform using
[Forms]![frm_NWBA_2]![datx] in the query criteria for the date where datx is
input in the subform (just like 'datbegin' in the parent form) but I still
get the not recognized as a valid field name or expression error.
I am a 'learn as I go' type and the discussion group helps me to learn when
I have exhausted other resources but I have not been able to find my answer
through fourms, discussions, etc. Does anyone have an answer?
TIA!