Sub FillDGV_Sales()
Try
Dim MYDOC_DIR As String = Environ("userprofile") & "\my documents"
Dim oFullPath As String = MYDOC_DIR & "\MagicBox.accdb"
'"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=App_Data\GC.accdb;"
Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & oFullPath & ";"
Dim sSQL As String
'sSQL = "SELECT Suppliers.SupplierName, Sum(DLookUp('Amount','Transactions','[Transaction Type] = " & SQLConvert("'Invoice'") & "')) AS Invoiced, Sum(DLookUp('Amount','Transactions',[Transaction Type]' = " & SQLConvert("'Payment'") & "')) AS Paid, [Invoiced]-[Paid] AS Balance " & _
'"FROM Suppliers INNER JOIN Transactions ON Suppliers.SupplierID = Transactions.SupplierID" & _
'"GROUP BY Suppliers.SupplierName"
sSQL = "SELECT Suppliers.SupplierName, [Invoiced]-[Paid] AS Balance, Sum(DLookUp('Amount','Transactions','[Transaction Type] = ''Invoice''')) AS Invoiced, Sum(DLookUp('Amount','Transactions','[Transaction Type] = ''Payment''')) AS Paid " & _
"FROM Suppliers INNER JOIN Transactions ON Suppliers.SupplierID = Transactions.SupplierID " & _
"GROUP BY Suppliers.SupplierName"
'" & SQLConvert(sSchool) & "'"
Dim connection As New OleDbConnection(connectionString)
Dim dataadapter As New OleDbDataAdapter(sSQL, connection)
Dim ds As New DataSet()
connection.Open()
dataadapter.Fill(ds, "Suppliers_table")
connection.Close()
DataGridView_Supplier.DataSource = ds
DataGridView_Supplier.DataMember = "Suppliers_table"
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE