لدي أستفسار :
عندما أضع على الفورم أكثر من داتا جريد واوصلهم بالجداول عن طريق الكود يتم إنشاء الجداول ويتم توصيلهم بالداتا جريد لكن لا تظهر النتيجة غير في أحدهم فقط وهي الأخيرة وهذا هو الكود المستخدم
Private Sub CommandButton3_Click()
Dim y, A, B, C, D As String
y = "Booz"
A = "Airport"
B = "Daily Errands"
C = "Morning Home Runs"
D = "Evening Home Runs"
db.Execute "drop view Booz_B"
db.Execute "create view Booz_B as select * from Customers_Account where SDate Between #" & Format(DTPicker1.Value, "m/d/yyyy") & "# And SDate <= #" & Format(DTPicker4.Value, "m/d/yyyy") & "# and SName = '" + y + "'"
db.Execute "drop view Booz_In"
db.Execute "create view Booz_In as select sum(Credit) from Booz_B"
If rs1.State = 1 Then rs1.Close
rs1.Open "Booz_In", db, 1, adLockOptimistic
Text6.Text = rs1("expr1000") & ""
db.Execute "drop view Booz_Out"
db.Execute "create view Booz_Out as select sum(Dept) from Booz_B"
If rs2.State = 1 Then rs2.Close
rs2.Open "Booz_Out", db, 1, adLockOptimistic
Text2.Text = rs2("expr1000") & ""
If Val(Text2.Text) > Val(Text6.Text) Then
Text4.Text = Val(Text2.Text) - Val(Text6.Text)
Label3.Caption = "Dept"
End If
If Val(Text6.Text) > Val(Text2.Text) Then
Text4.Text = Val(Text6.Text) - Val(Text2.Text)
Label3.Caption = "Credit"
End If
If Text2.Text = "" And Text6.Text = "" Then
Text4.Text = "No Balance"
End If
db.Execute "drop view Booz"
db.Execute "create view Booz as select Dept,Credit,Description,SDate,Backage,Client,VIP_Type from Customers_Account where SDate Between #" & Format(DTPicker4.Value, "m/d/yyyy") & "# And #" & Format(DTPicker3.Value, "m/d/yyyy") & "# and SName = '" + y + "'"
'If rs7.State = 1 Then rs7.Close
'rs7.CursorLocation = adUseClient
'rs7.Open "Customer", db, 1, adLockOptimistic
'Set DataGrid1.DataSource = rs7
db.Execute "drop view Booz_1"
db.Execute "create view Booz_1 as select Client,Dept,Credit,Description,SDate,Backage from Booz where VIP_Type = '" + A + "'"
If rs7.State = 1 Then rs7.Close
rs7.CursorLocation = adUseClient
rs7.Open "Booz_1", db, 1, adLockOptimistic
Set DataGrid1.DataSource = rs7
db.Execute "drop view Booz_2"
db.Execute "create view Booz_2 as select Client,Dept,Credit,Description,SDate,Backage from Booz where VIP_Type = '" + B + "'"
If rs7.State = 1 Then rs7.Close
rs7.CursorLocation = adUseClient
rs7.Open "Booz_2", db, 1, adLockOptimistic
Set DataGrid2.DataSource = rs7
db.Execute "drop view Booz_3"
db.Execute "create view Booz_3 as select Client,Dept,Credit,Description,SDate,Backage from Booz where VIP_Type = '" + C + "'"
If rs7.State = 1 Then rs7.Close
rs7.CursorLocation = adUseClient
rs7.Open "Booz_3", db, 1, adLockOptimistic
Set DataGrid3.DataSource = rs7
db.Execute "drop view Booz_4"
db.Execute "create view Booz_4 as select Client,Dept,Credit,Description,SDate,Backage from Booz where VIP_Type = '" + D + "'"
If rs7.State = 1 Then rs7.Close
rs7.CursorLocation = adUseClient
rs7.Open "Booz_4", db, 1, adLockOptimistic
Set DataGrid4.DataSource = rs7
db.Execute "drop view Cust_d"
db.Execute "create view Cust_d as select sum(Dept) from Booz"
If rs3.State = 1 Then rs3.Close
rs3.Open "Cust_d", db, 1, adLockOptimistic
Text7.Text = rs3("expr1000") & ""
db.Execute "drop view Cust_c"
db.Execute "create view Cust_c as select sum(Credit) from Booz"
If rs4.State = 1 Then rs4.Close
rs4.Open "Cust_c", db, 1, adLockOptimistic
Text8.Text = rs4("expr1000") & ""
If Label3.Caption = "Dept" Then
If Val(Text4.Text) + Val(Text7.Text) > Val(Text8.Text) Then
Text5.Text = Val(Val(Text4.Text) + Val(Text7.Text)) - Val(Text8.Text)
Label8.Caption = "Dept"
End If
If Val(Text4.Text) + Val(Text7.Text) < Val(Text8.Text) Then
Text5.Text = Val(Text8.Text) - Val(Val(Text4.Text) + Val(Text7.Text))
Label8.Caption = "Credit"
End If
End If
If Label3.Caption = "Credit" Then
If Val(Text4.Text) + Val(Text8.Text) > Val(Text7.Text) Then
Text5.Text = Val(Val(Text4.Text) + Val(Text8.Text)) - Val(Text7.Text)
Label8.Caption = "Credit"
End If
If Val(Text4.Text) + Val(Text8.Text) < Val(Text7.Text) Then
Text5.Text = Val(Text7.Text) - Val(Val(Text4.Text) + Val(Text8.Text))
Label8.Caption = "Dept"
End If
End If
End Sub