Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error 3129.

Status
Not open for further replies.

sonikudi

Technical User
Sep 9, 2007
81
US
Hi,

I have a query, works fine in Access but when i put it into VB it gives me a runtime error '3129' saying 'Invalid SQL statement; expected 'INSERT', 'DELETE', 'SELECT'..."
:(

Any idea how to fix this?
Thanks for any help.

Code:
Private Sub Weekly_Report_Click()

Dim qdf As DAO.QueryDef
Dim StrSQL As String


SrtSQL = "SELECT T1.[Item Num] AS [Part #], T2.Description, SUM(T1.[Batch Size]) AS Batch, SUM(T1.[Num defected]) AS Reject, T1.Reason, T1.Comments AS Notes" & _
" FROM [incoming inspec staub parts] AS T1, [Item Numbers] AS T2 " & _
" WHERE (T1.[Item Num]) = T2.[Item Num] And Vendor = 'Staub' And [Shipment Date] Between #" & _
Me.txtStartDate & "# AND #" & Me.txtEndDate & "# GROUP BY T1.[Item Num], T2.Description, T1.Vendor, T1.reason, T1.comments ORDER BY T1.[Item Num];"

Debug.Print StrSQL

Set qdf = CurrentDb.QueryDefs("WeeklyStaubRep")
'DoCmd.OutputTo acOutputQuery, WeeklyStaubRep, acFormatXLS, "StaubRep.xls", True
  
  'if query exists
  qdf.SQL = StrSQL

  DoCmd.OpenQuery qdf.Name
  DoCmd.Close acForm, "GetGraphDatesStaub", acSaveNo

End Sub

 
PLEASE DISREGARD THIS POST. THE PROBLEM IS FIXED.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top