S
sleek
Private Sub Item_No_AfterUpdate()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strsql As String
strsql = "SELECT * FROM [Job Items]" _
& "HAVING [Project]= '" & [Forms]![NDrawing Entry]![Project] & "' AND
[Partition]= '" & [Forms]![NDrawing Entry]![Partition] & "' AND [Section]= '"
& [Forms]![NDrawing Entry]![Sect] & "' AND [Sub Section]= '" &
[Forms]![NDrawing Entry]![Sub Sect] & "' AND [Drawing No]= '" &
[Forms]![NDrawing Entry]![Drawing No] & "' AND [Type]= '" & [Forms]![NDrawing
Entry]![Type] & "' AND [Item No]= '" & [Forms]![NDrawing Entry]![Drawing
Items].[Form]![Item No] & "';"
Set db = CurrentDb()
*Set rs = db.OpenRecordSet(strsql, dbOpenDynaset)
If Not rs.EOF Then
rs.MoveFirst
Me.Supplier = rs![Supplier]
Me.Quantity = rs![Quantity]
Me.Status = rs![Status]
Me.Due_Date = rs![Due Date]
Me.Category = rs![Category]
Me.W_O_No = rs![W/O No]
Me.P_O_No = rs![P/O No]
Me.P_O_Line_No = rs![P/O Line No]
End If
rs.Close
End Sub
basicly now the code is stuck at the (*) openrecordset call. It is returning
a 3091 runtime error, something about no grouping or aggregation. if i add a
grouped by call to the sql
strsql = "SELECT * FROM [Job Items]" _
& "Grouped BY [Item No] " _
& "HAVING [Project]= '" & [Forms]![NDrawing Entry]![Project] & "' AND
[Partition]= '" & [Forms]![NDrawing Entry]![Partition] & "' AND [Section]= '"
& [Forms]![NDrawing Entry]![Sect] & "' AND [Sub Section]= '" &
[Forms]![NDrawing Entry]![Sub Sect] & "' AND [Drawing No]= '" &
[Forms]![NDrawing Entry]![Drawing No] & "' AND [Type]= '" & [Forms]![NDrawing
Entry]![Type] & "' AND [Item No]= '" & [Forms]![NDrawing Entry]![Drawing
Items].[Form]![Item No] & "';"
i get 3131 runtime error (syntax error in from clause)
Help please, this piece of code has me going round in circles. i know the
actual code works as i put in a simplified query and it gave the correct
result. I have done my best to simplify the query, but it must be this
complex or i can not get the correct data from the table.
Can someone help me, is there something fundamentally wrong with the way i
have constructed the strsql???
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strsql As String
strsql = "SELECT * FROM [Job Items]" _
& "HAVING [Project]= '" & [Forms]![NDrawing Entry]![Project] & "' AND
[Partition]= '" & [Forms]![NDrawing Entry]![Partition] & "' AND [Section]= '"
& [Forms]![NDrawing Entry]![Sect] & "' AND [Sub Section]= '" &
[Forms]![NDrawing Entry]![Sub Sect] & "' AND [Drawing No]= '" &
[Forms]![NDrawing Entry]![Drawing No] & "' AND [Type]= '" & [Forms]![NDrawing
Entry]![Type] & "' AND [Item No]= '" & [Forms]![NDrawing Entry]![Drawing
Items].[Form]![Item No] & "';"
Set db = CurrentDb()
*Set rs = db.OpenRecordSet(strsql, dbOpenDynaset)
If Not rs.EOF Then
rs.MoveFirst
Me.Supplier = rs![Supplier]
Me.Quantity = rs![Quantity]
Me.Status = rs![Status]
Me.Due_Date = rs![Due Date]
Me.Category = rs![Category]
Me.W_O_No = rs![W/O No]
Me.P_O_No = rs![P/O No]
Me.P_O_Line_No = rs![P/O Line No]
End If
rs.Close
End Sub
basicly now the code is stuck at the (*) openrecordset call. It is returning
a 3091 runtime error, something about no grouping or aggregation. if i add a
grouped by call to the sql
strsql = "SELECT * FROM [Job Items]" _
& "Grouped BY [Item No] " _
& "HAVING [Project]= '" & [Forms]![NDrawing Entry]![Project] & "' AND
[Partition]= '" & [Forms]![NDrawing Entry]![Partition] & "' AND [Section]= '"
& [Forms]![NDrawing Entry]![Sect] & "' AND [Sub Section]= '" &
[Forms]![NDrawing Entry]![Sub Sect] & "' AND [Drawing No]= '" &
[Forms]![NDrawing Entry]![Drawing No] & "' AND [Type]= '" & [Forms]![NDrawing
Entry]![Type] & "' AND [Item No]= '" & [Forms]![NDrawing Entry]![Drawing
Items].[Form]![Item No] & "';"
i get 3131 runtime error (syntax error in from clause)
Help please, this piece of code has me going round in circles. i know the
actual code works as i put in a simplified query and it gave the correct
result. I have done my best to simplify the query, but it must be this
complex or i can not get the correct data from the table.
Can someone help me, is there something fundamentally wrong with the way i
have constructed the strsql???