Hey guys,
Followin is my query that gives me the error saying "Query input must contain at least one table or query" for the StrSQL2. StrSQL qry works fine, does exactly what its supposed to do
Any help on the cause of the error will be much appreciated..thanks
Followin is my query that gives me the error saying "Query input must contain at least one table or query" for the StrSQL2. StrSQL qry works fine, does exactly what its supposed to do
Code:
Private Sub Graph_it_Click()
Dim StrSQL As String
Dim StrSQL2 As String
Dim qdf As QueryDef
Dim stDocName As String
stDocName = "StaubGraphs"
On Error GoTo qry
' Deletes the queri if it exists
qry:
SrtSQL = "SELECT [Item Num], [Shipment Date], SUM([Num Defected]) AS SumNumDefected, SUM([Batch Size]) AS SumBatchSize " & _
"FROM [incoming inspec staub parts] " & _
"WHERE Vendor= 'Staub' And [Shipment Date] Between #" & _
Me.txtStartDate & "# AND #" & Me.txtEndDate & "# GROUP BY [Item Num],[Shipment Date];"
CurrentDb.QueryDefs.Delete ("qryStaubUpdateVB")
' Create new QueryDef object, don't really need it once the query exists
Set qdf = CurrentDb.CreateQueryDef("qryStaubUpdateVB", SrtSQL)
[red]StrSQL2 = "SELECT t1.[Item Num], t2.Description, t1.[Shipment Date],(t1.SumNumDefected/t1.SumBatchSize)*100 AS PercentRejected into table1" & _
"FROM qryStaubUpdateVB AS t1, [Item numbers] AS t2 WHERE (t1.[Item Num])=(t2.[Item Num]);"[/red]
CurrentDb.Execute StrSQL2, dbFailOnError
DoCmd.Close acForm, "GetGraphDatesStaub", acSaveNo
CurrentDb.TableDefs.Delete ("qrySummaryStaubTable")
CurrentDb.TableDefs.Refresh
CurrentDb.QueryDefs.Refresh
Set dbs = Nothing
End Sub
Any help on the cause of the error will be much appreciated..thanks