Error
'The multi-part identifier "ar_update.Id" could not be bound.'
as line denoted in sql script.
I also tried other columns for the errant join to try to prompt different errors and gives same error results.
Why/How to qualify the 'inner' processing set back to the 'update' set?
update ar_update
set ar_update.[GLEntry_Amount] = ar_sum.[GLEntry_Amount_sum]
from [dbo].[ASL_Result_VGO] as ar_update
join (select ar.[Id] as [Id]
,ar.[Company Id] as [Company Id]
,ar.[Schedule Name] as [Schedule Name]
,ar.[Line No_] as [Line No_]
,ar.[Row No_] as [Row No_]
,ar.[Posting Date] as [Posting Date]
,ar.[Business Centre Code] as [Business Centre Code]
,ar.[Site Locations Code] as [Site Locations Code]
,GLEntry_Amount_sum =
(select sum(are.[GLEntry_Amount])
from [dbo].[ASL_Result_VGO] as are
where are.[Company Id] = ar.[Company Id] and
are.[Schedule Name] = ar.[Schedule Name] and
are.[Posting Date] = ar.[Posting Date] and
are.[Business Centre Code] = ar.[Business Centre Code] and
are.[Site Locations Code] = ar.[Site Locations Code] and
are.[Row No_] in ( select * from dbo.udf_range_expand_VGO(ar.[Totaling]) )
)
from [dbo].[ASL_Result_VGO] as ar
where ar.[Id] = ar_update.[Id] -- The multi-part identifier "ar_update.Id" could not be bound.
) ar_sum on ar_update.[Id] = ar_sum.[Id]
where ar_update.[Totaling Type] = 2 and -- formulas
len(trim(ar_update.[Totaling])) > 0 and
charindex('..', ar_update.[Totaling]) > 0 -- P ranges
this happened because on where ar.[Id] = ar_update.[Id] because ar_update.[Id] is not a value it is a multivalued type, it's like you were comparing a list with an integer, try this
update ar_update
set ar_update.[GLEntry_Amount] = ar_sum.[GLEntry_Amount_sum]
from [dbo].[ASL_Result_VGO] as ar_update
join (select ar.[Id] as [Id]
,ar.[Company Id] as [Company Id]
,ar.[Schedule Name] as [Schedule Name]
,ar.[Line No_] as [Line No_]
,ar.[Row No_] as [Row No_]
,ar.[Posting Date] as [Posting Date]
,ar.[Business Centre Code] as [Business Centre Code]
,ar.[Site Locations Code] as [Site Locations Code]
,GLEntry_Amount_sum = (select sum(are.[GLEntry_Amount])
from [dbo].[ASL_Result_VGO] as are
where are.[Company Id] = ar.[Company Id] and
are.[Schedule Name] = ar.[Schedule Name] and
are.[Posting Date] = ar.[Posting Date] and
are.[Business Centre Code] = ar.[Business Centre Code] and
are.[Site Locations Code] = ar.[Site Locations Code] and
are.[Row No_] in ( select * from dbo.udf_range_expand_VGO(ar.[Totaling]) )
)
from [dbo].[ASL_Result_VGO] as ar
) ar_sum on ar_update.[Id] = ar_sum.[Id]
where ar_update.[Totaling Type] = 2 and -- formulas
len(trim(ar_update.[Totaling])) > 0 and
charindex('..', ar_update.[Totaling]) > 0
I'm working on a pop up box (userform) in Access and the idea is the user will check the days of the week they want daily work tasks to appear. But I'm getting a type mismatch error on my line For Each c In Me.Controls and I can't figure out why.
I am able to use this same code in Excel VBA with another userform without a problem but I'm guessing something is getting lost in translation??
Here is the full code...
Private Sub CheckBox1_Click()
End Sub
Private Sub CheckBox2_Click()
End Sub
Private Sub CheckBox3_Click()
End Sub
Private Sub CheckBox4_Click()
End Sub
Private Sub CheckBox5_Click()
End Sub
Private Sub CheckBox6_Click()
End Sub
Private Sub CheckBox7_Click()
End Sub
Public Property Get IsCancelled() As Boolean
IsCancelled = cancelled
End Property
Private Sub OkButton_Click()
Dim c As Control
Dim StrSQL As String
For Each c In Me.Controls '<----- Errors out with Type mismatch
If TypeOf c Is MSForms.CheckBox Then
If c Then
Select Case c.Name
Case "CheckBox1"
'Monday
Hide
'Change Notice
CurrentDb.Execute ("INSERT INTO tblTasks ([Task Name], [Task Description], [Company], [Priority], [Status], [DueDate], [User ID]) VALUES ('Change Notice', 'Daily Task', 'Ginny''s', '(2) Normal', '0', DateAdd('d',8-Weekday(Date(),2),Date()), 'Frontiera')")
'Daily Checks
CurrentDb.Execute ("INSERT INTO tblTasks ([Task Name], [Task Description], [Company], [Priority], [Status], [DueDate], [User ID]) VALUES ('Daily Checks', 'Daily Task', 'Ginny''s', '(2) Normal', '0', DateAdd('d',8-Weekday(Date(),2),Date()), 'Frontiera')")
Case "CheckBox2"
'Tuesday
Hide
'Change Notice
CurrentDb.Execute ("INSERT INTO tblTasks ([Task Name], [Task Description], [Company], [Priority], [Status], [DueDate], [User ID]) VALUES ('Change Notice', 'Daily Task', 'Ginny''s', '(2) Normal', '0', DateAdd('d',8-Weekday(Date(),3),Date()), 'Frontiera')")
'Daily Checks
CurrentDb.Execute ("INSERT INTO tblTasks ([Task Name], [Task Description], [Company], [Priority], [Status], [DueDate], [User ID]) VALUES ('Daily Checks', 'Daily Task', 'Ginny''s', '(2) Normal', '0', DateAdd('d',8-Weekday(Date(),3),Date()), 'Frontiera')")
Case "CheckBox3"
'Wednesday
Hide
'Change Notice
CurrentDb.Execute ("INSERT INTO tblTasks ([Task Name], [Task Description], [Company], [Priority], [Status], [DueDate], [User ID]) VALUES ('Change Notice', 'Daily Task', 'Ginny''s', '(2) Normal', '0', DateAdd('d',8-Weekday(Date(),4),Date()), 'Frontiera')")
'Daily Checks
CurrentDb.Execute ("INSERT INTO tblTasks ([Task Name], [Task Description], [Company], [Priority], [Status], [DueDate], [User ID]) VALUES ('Daily Checks', 'Daily Task', 'Ginny''s', '(2) Normal', '0', DateAdd('d',8-Weekday(Date(),4),Date()), 'Frontiera')")
Case "CheckBox4"
'Thursday
Hide
'Change Notice
CurrentDb.Execute ("INSERT INTO tblTasks ([Task Name], [Task Description], [Company], [Priority], [Status], [DueDate], [User ID]) VALUES ('Change Notice', 'Daily Task', 'Ginny''s', '(2) Normal', '0', DateAdd('d',8-Weekday(Date(),5),Date()), 'Frontiera')")
'Daily Checks
CurrentDb.Execute ("INSERT INTO tblTasks ([Task Name], [Task Description], [Company], [Priority], [Status], [DueDate], [User ID]) VALUES ('Daily Checks', 'Daily Task', 'Ginny''s', '(2) Normal', '0', DateAdd('d',8-Weekday(Date(),5),Date()), 'Frontiera')")
Case "CheckBox5"
'Friday
Hide
'Change Notice
CurrentDb.Execute ("INSERT INTO tblTasks ([Task Name], [Task Description], [Company], [Priority], [Status], [DueDate], [User ID]) VALUES ('Change Notice', 'Daily Task', 'Ginny''s', '(2) Normal', '0', DateAdd('d',8-Weekday(Date(),6),Date()), 'Frontiera')")
'Daily Checks
CurrentDb.Execute ("INSERT INTO tblTasks ([Task Name], [Task Description], [Company], [Priority], [Status], [DueDate], [User ID]) VALUES ('Daily Checks', 'Daily Task', 'Ginny''s', '(2) Normal', '0', DateAdd('d',8-Weekday(Date(),6),Date()), 'Frontiera')")
Case "CheckBox6"
'Saturday
Hide
'Change Notice
CurrentDb.Execute ("INSERT INTO tblTasks ([Task Name], [Task Description], [Company], [Priority], [Status], [DueDate], [User ID]) VALUES ('Change Notice', 'Daily Task', 'Ginny''s', '(2) Normal', '0', DateAdd('d',8-Weekday(Date(),7),Date()), 'Frontiera')")
'Daily Checks
CurrentDb.Execute ("INSERT INTO tblTasks ([Task Name], [Task Description], [Company], [Priority], [Status], [DueDate], [User ID]) VALUES ('Daily Checks', 'Daily Task', 'Ginny''s', '(2) Normal', '0', DateAdd('d',8-Weekday(Date(),7),Date()), 'Frontiera')")
Case "CheckBox7"
'Sunday
Hide
'Change Notice
CurrentDb.Execute ("INSERT INTO tblTasks ([Task Name], [Task Description], [Company], [Priority], [Status], [DueDate], [User ID]) VALUES ('Change Notice', 'Daily Task', 'Ginny''s', '(2) Normal', '0', DateAdd('d',8-Weekday(Date(),8),Date()), 'Frontiera')")
'Daily Checks
CurrentDb.Execute ("INSERT INTO tblTasks ([Task Name], [Task Description], [Company], [Priority], [Status], [DueDate], [User ID]) VALUES ('Daily Checks', 'Daily Task', 'Ginny''s', '(2) Normal', '0', DateAdd('d',8-Weekday(Date(),8),Date()), 'Frontiera')")
Case Else
End Select
End If
End If
Next c
End Sub
Private Sub CancelButton_Click()
OnCancel
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = VbQueryClose.vbFormControlMenu Then
Cancel = True
OnCancel
End If
End Sub
Private Sub OnCancel()
cancelled = True
Hide
End Sub
Access has its own controls that have nothing to do with MSForms.
If the form is a MSForms form use
Dim c As MSForms.Control
...
If TypeOf c Is MSForms.CheckBox Then
...
If the form is an Access form
Dim c As Control
...
If TypeOf c Is CheckBox Then
...
Also, if you are using only Access forms, you can remove the Reference to MSForms in the VBA code editor in menu Tools > References.
I'm stuck on a portion of code where I can not figure out how to use ISNULL correctly.
I'm trying to find all sales prices for an item by location and by variant code. The issue is that not all items with variants are priced in the sales price table at the variant level. I'm trying to say if there is no variant match, find where variant = ''.
SELECT [Item Ledger].[Location Code], [Item Ledger].[Item No_] AS "No_", [Item Ledger].[Variant Code]
, (SELECT [Item].[Description] FROM [Wings$Item] AS "Item" WHERE [Item].[No_] = [Item Ledger].[Item No_]) AS "Description"
, (SELECT [Item Variant].[Variant Dimension 1] FROM [Wings$Item Variant Registration] AS "Item Variant" WHERE [Item Variant].[Item No_] = [Item Ledger].[Item No_]
AND [Item Variant].[Variant] = [Item Ledger].[Variant Code]) AS "Color"
, (SELECT [Item Variant].[Variant Dimension 2] FROM [Wings$Item Variant Registration] AS "Item Variant" WHERE [Item Variant].[Item No_] = [Item Ledger].[Item No_]
AND [Item Variant].[Variant] = [Item Ledger].[Variant Code]) AS "Size"
, (SELECT [Item].[Vendor No_] FROM [Wings$Item] AS "Item" WHERE [Item].[No_] = [Item Ledger].[Item No_]) AS "Vendor No."
, (SELECT [Item].[Division Code] FROM [Wings$Item] AS "Item" WHERE [Item].[No_] = [Item Ledger].[Item No_]) AS "Division Code"
, (SELECT [Item].[Item Category Code] FROM [Wings$Item] AS "Item" WHERE [Item].[No_] = [Item Ledger].[Item No_]) AS "Item Category Code"
, (SELECT [Item Category].[Description] FROM [Wings$Item Category] AS "Item Category" WHERE [Item Category].[Code] = [Item Ledger].[Item Category Code]) AS "Item Cat. Description"
, (SELECT [Item].[Product Group Code] FROM [Wings$Item] AS "Item" WHERE [Item].[No_] = [Item Ledger].[Item No_]) AS "Product Group Code"
, (SELECT [Product Group].[Description] FROM [Wings$Product Group] AS "Product Group" WHERE [Product Group].[Code] = [Item Ledger].[Product Group Code]) AS "Prod. Group Description"
, (SELECT CAST([Item].[Last Direct Cost] AS decimal(18,2)) FROM [Wings$Item] AS "Item" WHERE [Item].[No_] = [Item Ledger].[Item No_]) AS "Last Cost"
, (SELECT DISTINCT CAST(MAX([Sales Price].[Unit Price]) as decimal(18,2))
FROM [Wings$Sales Price] AS "Sales Price", [Wings$Store Price Group] AS "Store Price"
WHERE EXISTS
(SELECT DISTINCT [Store Price].[Store]
, [Sales Price].[Item No_]
, (SELECT [Item].[Description] FROM [Wings$Item] AS "Item" WHERE [Item].[No_] = [Sales Price].[Item No_]) AS "Description"
, [Sales Price].[Variant Code]
, [Sales Price].[Sales Code]
, CAST([Sales Price].[Unit Price] as decimal(18,2)) AS "Unit Price"
FROM [Wings$Sales Price] AS "Sales Price" JOIN [Wings$Picking _ Receiving lines] AS "Picking Lines" ON [Sales Price].[Item No_] = [Picking Lines].[Item No_]
JOIN [Wings$Store Price Group] AS "Store Price" ON [Store Price].[Price Group Code] = [Sales Price].[Sales Code]
AND [Store Price].[Store] = [Picking Lines].[Shortcut Dimension 1 Code] WHERE [Sales Price].[Starting Date] > [Sales Price].[Ending Date])
AND [Store Price].[Store] = [Item Ledger].[Location Code] AND [Sales Price].[Item No_] = [Item Ledger].[Item No_]
AND [Sales Price].[Variant Code] = [Item Ledger].[Variant Code] AND [Store Price].[Price Group Code] = [Sales Price].[Sales Code]) AS "Retail Price"
, (SELECT MIN([Purch Rec].[Posting Date]) FROM [Wings$Purch_ Rcpt_ Line] AS "Purch Rec" WHERE [Purch Rec].[No_] = [Item Ledger].[Item No_] AND [Purch Rec].[Variant Code] = [Item Ledger].[Variant Code])
AS "First Rec Date"
, (SELECT MAX([Purch Rec].[Posting Date]) FROM [Wings$Purch_ Rcpt_ Line] AS "Purch Rec" WHERE [Purch Rec].[No_] = [Item Ledger].[Item No_] AND [Purch Rec].[Variant Code] = [Item Ledger].[Variant Code])
AS "Last Rec Date"
, (SELECT MAX([Sales Line].[Date]) FROM [Wings$Trans_ Sales Entry] AS "Sales Line" WHERE [Sales Line].[Item No_] = [Item Ledger].[Item No_] AND [Sales Line].[Variant Code] = [Item Ledger].[Variant Code]
AND [Sales Line].[Store No_] = [Item Ledger].[Location Code]) AS "Last Sold Date"
, (SELECT CAST(SUM([Value Entry].[Item Ledger Entry Quantity]) AS decimal(18,0)) FROM [Wings$Value Entry] AS "Value Entry" WHERE [Value Entry].[Item No_] = [Item Ledger].[Item No_]
AND [Value Entry].[Variant Code] = [Item Ledger].[Variant Code] AND [Value Entry].[Location Code] = [Item Ledger].[Location Code] AND [Value Entry].[Posting Date] <= '20161201') AS "Beg. Balance"
, (SELECT CAST(SUM([Transfer Shipment].[Quantity]) AS decimal(18,0)) FROM [Wings$Transfer Shipment Line] AS "Transfer Shipment" WHERE [Transfer Shipment].[Item No_] = [Item Ledger].[Item No_]
AND [Transfer Shipment].[Variant Code] = [Item Ledger].[Variant Code] AND [Transfer Shipment].[Transfer-from Code] = [Item Ledger].[Location Code]) AS "Outbound Transfers"
, (SELECT CAST(SUM([Transfer Receipt].[Quantity]) AS decimal(18,0)) FROM [Wings$Transfer Receipt Line] AS "Transfer Receipt" WHERE [Transfer Receipt].[Item No_] = [Item Ledger].[Item No_]
AND [Transfer Receipt].[Variant Code] = [Item Ledger].[Variant Code] AND [Transfer Receipt].[Transfer-to Code] = [Item Ledger].[Location Code]) AS "Inbound Transfers"
, (SELECT CAST(SUM([Purch. Rec.].[Quantity]) AS decimal(18,0)) FROM [Wings$Purch_ Rcpt_ Line] AS "Purch. Rec." WHERE [Purch. Rec.].[No_] = [Item Ledger].[Item No_]
AND [Purch. Rec.].[Variant Code] = [Item Ledger].[Variant Code] AND [Purch. Rec.].[Location Code] = [Item Ledger].[Location Code]) AS "YTD Purchase Receipts"
, (SELECT CAST(SUM([Transaction Register].[Quantity]) as decimal(18,0)) FROM [Wings$Trans_ Sales Entry] AS "Transaction Register"
WHERE [Item Ledger].[Item No_] = [Transaction Register].[Item No_] AND [Item Ledger].[Variant Code] = [Transaction Register].[Variant Code]
AND [Item Ledger].[Location Code] = [Transaction Register].[Store No_]) AS "YTD Sales"
, (SELECT CAST(SUM([Transaction Register].[Quantity]) as decimal(18,0)) FROM [Wings$Trans_ Sales Entry] AS "Transaction Register"
WHERE [Item Ledger].[Item No_] = [Transaction Register].[Item No_] AND [Item Ledger].[Variant Code] = [Transaction Register].[Variant Code]
AND [Item Ledger].[Location Code] = [Transaction Register].[Store No_] AND [Transaction Register].[Date] >= DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) -1, 0)
AND [Transaction Register].[Date] < DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) , 0)) AS "Last Month Sales"
, (SELECT CAST(SUM([Transaction Register].[Quantity]) as decimal(18,0)) FROM [Wings$Trans_ Sales Entry] AS "Transaction Register"
WHERE [Item Ledger].[Item No_] = [Transaction Register].[Item No_] AND [Item Ledger].[Variant Code] = [Transaction Register].[Variant Code]
AND [Item Ledger].[Location Code] = [Transaction Register].[Store No_] AND [Transaction Register].[Date] >= DATEADD(DAY, 1-DAY(GETDATE()), GETDATE())
AND [Transaction Register].[Date] < EOMONTH(GETDATE())) AS "Current Month Sales"
, (SELECT CAST(SUM([Transfer Line].[Outstanding Quantity]) AS decimal(18,0)) FROM [Wings$Transfer Line] AS "Transfer Line" WHERE [Transfer Line].[Item No_] = [Item Ledger].[Item No_]
AND [Transfer Line].[Variant Code] = [Item Ledger].[Variant Code] AND [Transfer Line].[Transfer-to Code] = [Item Ledger].[Location Code]) AS "Current In-Transit to Store"
, (SELECT CAST(SUM([Item Ledger].[Quantity]) as decimal(18,0))) AS "Current on Hand"
, (SELECT CAST(SUM([Value Entry].[Item Ledger Entry Quantity]) as decimal(18,0)) FROM [Wings$Value Entry] AS "Value Entry" WHERE [Value Entry].[Item No_] = [Item Ledger].[Item No_]
AND [Value Entry].[Variant Code] = [Item Ledger].[Variant Code] AND [Value Entry].[Location Code] = [Item Ledger].[Location Code] AND [Value Entry].[Location Code] LIKE '9%') AS "Whse Inv."
, (SELECT CAST(SUM([Value Entry].[Item Ledger Entry Quantity]) as decimal(18,0)) FROM [Wings$Value Entry] AS "Value Entry" WHERE [Value Entry].[Item No_] = [Item Ledger].[Item No_]
AND [Value Entry].[Variant Code] = [Item Ledger].[Variant Code] AND [Value Entry].[Location Code] = [Item Ledger].[Location Code] AND [Value Entry].[Location Code] NOT LIKE '9%') AS "Store Inv."
, (SELECT CAST(SUM([Purchase Line].[Outstanding Quantity]) as decimal(18,0)) FROM [Wings$Purchase Line] AS "Purchase Line" WHERE [Item Ledger].[Item No_] = [Purchase Line].[No_]
AND [Purchase Line].[Location Code] = [Item Ledger].[Location Code] AND [Purchase Line].[Variant Code] = [Item Ledger].[Variant Code]) AS "Qty. on PO"
FROM [Wings$Item Ledger Entry] AS "Item Ledger", [Wings$Store Price Group] AS "Store Price" WHERE [Item Ledger].[Location Code] = [Store Price].[Store] AND [Item Ledger].[Location Code] = [Store Price].[Store]
GROUP BY [Item Ledger].[Location Code], [Item Ledger].[Item No_], [Item Ledger].[Variant Code], [Item Ledger].[Item Category Code], [Item Ledger].[Product Group Code], [Store Price].[Price Group Code], [Store Price].[Store]
I have a combobox on a datagridview. I am able to populate the values of the combobox, but what I am failing to do is to populate the data base value into the combobox "text" when the datagridview is loading.
I hope this makes sense. Basically I just want the data returned to reflect in the combobox Display.
Your assistance will be highly appreciated.
Dim cbo As DataGridViewComboBoxColumn
If GlobalVariables.UsrSite = 0 Then
SQL.ReadQuery("Select LogsReason as [Logs Update], IncNo as [Number], SiteName As [Site Name], FleetNo As [Fleet No], FleetType As [Fleet Type], Location,
SMR as [Hours], TimeDown As [Down Time], EstTimeUp as [Est Repair], DateDiff(d, TimeDown, GetDate()) as [Days Down]
from UDOData where status = 'Down' order by [Days Down] Desc")
Else
SQL.ReadQuery("Select LogsReason as [Logs Update], IncNo as [Number], SiteName As [Site Name], FleetNo As [Fleet No], FleetType As [Fleet Type], Location,
SMR as [Hours], TimeDown As [Down Time], EstTimeUp as [Est Repair], DateDiff(d, TimeDown, GetDate()) as [Days Down] from UDOData
Where SiteID = " & GlobalVariables.UsrSite & " and Status = 'Down' order by [Days Down] Desc")
End If
dgvUDO.DataSource = SQL.SQLDS.Tables(0)
cbo.DataSource = SQL.SQLDS.Tables(0)
cbo.DisplayMember = "Logs Update"
cbo.ValueMember = "Logs Update"
cbo.DataPropertyName = "Logs Update"
I get exception error saying "logs Update" does not exist, but it loads in the datagridview.
I ended up doing this, which worked for me.
Dim cbo As DataGridViewComboBoxColumn
cbo = dgvUDO.Columns("cboLogsUDO")
Dim AltDb As New DataTable
SQL.ReadQuery("Select Descrip from dbo.UDOLogs")
AltDb = SQL.SQLDS.Tables(0)
'LOAD DATA GRID VIEW DATA
If GlobalVariables.UsrSite = 0 Then
SQL.ReadQuery("Select ID, LogsReason as [Logs Update], IncNo as [Number], SiteName As [Site Name], FleetNo As [Fleet No], FleetType As [Fleet Type], Location,
SMR as [Hours], TimeDown As [Down Time], EstTimeUp as [Est Repair], DateDiff(d, TimeDown, GetDate()) as [Days Down]
from UDOData where status = 'Down' order by [Days Down] Desc")
Else
SQL.ReadQuery("Select ID, LogsReason as [Logs Update], IncNo as [Number], SiteName As [Site Name], FleetNo As [Fleet No], FleetType As [Fleet Type], Location,
SMR as [Hours], TimeDown As [Down Time], EstTimeUp as [Est Repair], DateDiff(d, TimeDown, GetDate()) as [Days Down] from UDOData
Where SiteID = " & GlobalVariables.UsrSite & " and Status = 'Down' order by [Days Down] Desc")
End If
'SET DATA GRIDVIEW DATA SOURCE
dt = SQL.SQLDS.Tables(0)
dgvUDO.DataSource = dt
dgvUDO.Rows(0).Selected = True
'LOAD UPDATE COMMAND FOR DATA GRIDVIEW CHANGES
SQL.SQLDA.UpdateCommand = New SqlClient.SqlCommandBuilder(SQL.SQLDA).GetUpdateCommand
'HIDE UNWANTED COLUMNS
dgvUDO.Columns("Logs Update").Visible = False
dgvUDO.Columns("ID").Visible = False
'SET COMBOBOX ATTRIBUTES
cbo.DataSource = AltDb
cbo.DisplayMember = "Descrip"
cbo.ValueMember = "Descrip"
cbo.DataPropertyName = "Logs Update"
This gives me the ability to call the value in the returned db for the datagridview as the combobox "text" value, but show the drop down items as the items in another table.
SELECT DISTINCT [SC Vermorel SRL$Production Order].No_,
[SC Vermorel SRL$Production Order].[Replan Ref_ No_],
[SC Vermorel SRL$Production Order].Description,
[SC Vermorel SRL$Production Order].[Source No_],
[SC Vermorel SRL$Production Order].[Routing No_],
[SC Vermorel SRL$Production Order].Quantity,
[SC Vermorel SRL$Production Order].[Old Prod_ Order No_],
[SC Vermorel SRL$Routing Line].[Run Time],
[SC Vermorel SRL$Routing Line].[Run Time] * [SC Vermorel SRL$Production Order].Quantity AS TotalOre,
[SC Vermorel SRL$Prod_ Order Line].[Finished Quantity],
SUM([SC Vermorel SRL$ProductieZilnica].[Cantitate sudura]) AS [Cantitate sudura],
SUM([SC Vermorel SRL$ProductieZilnica].[Cantitate montaj]) AS [Cantitate montaj]
FROM [SC Vermorel SRL$Production Order]
INNER JOIN [SC Vermorel SRL$Routing Line]
ON [SC Vermorel SRL$Production Order].[Routing No_] = [SC Vermorel SRL$Routing Line].[Routing No_]
INNER JOIN [SC Vermorel SRL$Prod_ Order Line]
ON [SC Vermorel SRL$Production Order].No_ = [SC Vermorel SRL$Prod_ Order Line].[Prod_ Order No_]
INNER JOIN [SC Vermorel SRL$ProductieZilnica]
ON [SC Vermorel SRL$Production Order].No_ = [SC Vermorel SRL$ProductieZilnica].RPO
WHERE ([SC Vermorel SRL$Production Order].Status = 3)
AND ([SC Vermorel SRL$Production Order].[Location Code] = 'MACH FIN')
AND ([SC Vermorel SRL$Production Order].[Gen_ Prod_ Posting Group] = 'FINISHED G')
AND ([SC Vermorel SRL$Routing Line].No_ = '150')
GROUP BY [SC Vermorel SRL$Production Order].No_
I need to attach the sum of all the entries from another table ([SC Vermorel SRL$ProductieZilnica]) which corresponds to each distinct No_ from [SC Vermorel SRL$Production Order] table.
I cant for the love of God make it work. Can someone point me in the right direction?
At first, use table aliases - it will make your query more readable.
If you are using GROUP BY you need to add all columns, except one that are in aggregation function (you got SUM) like:
SELECT PO.No_,
PO.[Replan Ref_ No_],
PO.[Description],
PO.[Source No_],
PO.[Routing No_],
PO.Quantity,
PO.[Old Prod_ Order No_],
RL.[Run Time],
RL.[Run Time] * PO.Quantity AS TotalOre,
POL.[Finished Quantity],
SUM(PZ.[Cantitate sudura]) AS [Cantitate sudura],
SUM(PZ.[Cantitate montaj]) AS [Cantitate montaj]
FROM [SC Vermorel SRL$Production Order] PO
INNER JOIN [SC Vermorel SRL$Routing Line] RL
ON PO.[Routing No_] = RL.[Routing No_]
INNER JOIN [SC Vermorel SRL$Prod_ Order Line] POL
ON PO.No_ = POL.[Prod_ Order No_]
INNER JOIN [SC Vermorel SRL$ProductieZilnica] PZ
ON PO.No_ = PZ.RPO
WHERE (PO.Status = 3) AND (PO.[Location Code] = 'MACH FIN') AND
(PO.[Gen_ Prod_ Posting Group] = 'FINISHED G') AND (RL.No_ = '150')
GROUP BY PO.No_,
PO.[Replan Ref_ No_],
PO.[Description],
PO.[Source No_],
PO.[Routing No_],
PO.Quantity,
PO.[Old Prod_ Order No_],
RL.[Run Time],
PO.Quantity,
POL.[Finished Quantity]