Hello,
I need help with an application I'm working on. I have made a connection with a local Access database using bounded controls. Everything runs fine and I am able to load and display the Customers data and the Orders data just fine. Now what I am trying to do is load the Customers form and be able to double-click on a customer and pop up the Orders form but only with that customer's orders (not the whole orders table).
I have my SQL statement that I believe is right because I ran it directly on the database and it worked perfectly. So I'm not sure what I'm missing in vb.net. When I run my application and double-click on a customer I do get the orders form to pop up but the rows and columns are not populated. Here is my code for this:
Private Sub frmOrders_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim strCustomerOrders As String
If frmCustomers.CustomersDataGridView.CurrentRow IsNot Nothing Then
Me.MdiParent = frmMainMDI
strCustomerOrders =
"SELECT Orders.OrderID, Orders.OrderDate, Orders.RequiredDate, Orders.ShippedDate,
Shippers.CompanyName, Orders.ShipName" & _
"FROM Customers INNER JOIN Shippers INNER JOIN Orders ON Shippers.ShipperID =
Orders.ShipVia ON Customers.CustomerID = Orders.CustomerID" & _
"WHERE Customers.CustomerID = Orders.CustomerID" & _
"ORDER BY Orders.OrderID;"
Me.RecordSource = strCustomerOrders
End If
End Sub
I know this is on the frmOrders_load event but I am calling this method from the Customersdatagridview_doubleclick event so that is not a problem.
I need help with an application I'm working on. I have made a connection with a local Access database using bounded controls. Everything runs fine and I am able to load and display the Customers data and the Orders data just fine. Now what I am trying to do is load the Customers form and be able to double-click on a customer and pop up the Orders form but only with that customer's orders (not the whole orders table).
I have my SQL statement that I believe is right because I ran it directly on the database and it worked perfectly. So I'm not sure what I'm missing in vb.net. When I run my application and double-click on a customer I do get the orders form to pop up but the rows and columns are not populated. Here is my code for this:
Private Sub frmOrders_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim strCustomerOrders As String
If frmCustomers.CustomersDataGridView.CurrentRow IsNot Nothing Then
Me.MdiParent = frmMainMDI
strCustomerOrders =
"SELECT Orders.OrderID, Orders.OrderDate, Orders.RequiredDate, Orders.ShippedDate,
Shippers.CompanyName, Orders.ShipName" & _
"FROM Customers INNER JOIN Shippers INNER JOIN Orders ON Shippers.ShipperID =
Orders.ShipVia ON Customers.CustomerID = Orders.CustomerID" & _
"WHERE Customers.CustomerID = Orders.CustomerID" & _
"ORDER BY Orders.OrderID;"
Me.RecordSource = strCustomerOrders
End If
End Sub
I know this is on the frmOrders_load event but I am calling this method from the Customersdatagridview_doubleclick event so that is not a problem.