!
*.mdb Access 2010
:
, 40% . , , 50%. : .
tbl_TehniksID_Tehniks | Date_Dawn | Sum_Remonta | 1556 | 16.06.2015 | 584.00 | 1557 | 21.06.2015 | 1347.00 |
|
ID_Tehniks - , Date_Dawn - , Sum_Remonta -
tbl_Okazanie_UslugID | ID_Tehniks | ID_Goods | Qty | Price | Price_Det | 111 | 1556 | 84 | 1 | 0.00 | 84.00 | 112 | 1556 | null | 1 | 500.00 | 0.00 |
|
ID_Goods - , Qty - -, Price - , Price_Det -
tbl_Current_TehniksID_Current_Remont | ID_Tehniks | ID_Sotrudnik | 1211 | 111 | 1 |
|
ID_Current_Remont - , ID_Tehniks - , ID_Sotrudnik -
tbl_Sotrudniki ID_Sotrudnik - , Stavka -
qry_SumRem
SELECT Sum(tbl_Tehniks.Sum_Remonta) AS [Sum-Sum_Remonta], tbl_Current_Tehniks.ID_Sotrudnik
FROM tbl_Tehniks INNER JOIN tbl_Current_Tehniks ON tbl_Tehniks.ID_Tehniks = tbl_Current_Tehniks.ID_Tehniks
WHERE (((tbl_Tehniks.Date_Dawn) Between dIn() And dOut()))
GROUP BY tbl_Current_Tehniks.ID_Sotrudnik;
qry_SumDetIng
SELECT Sum([Qty]*[price_Det]) AS SumDet, tbl_Current_Tehniks.ID_Sotrudnik
FROM (tbl_Tehniks INNER JOIN tbl_Current_Tehniks ON tbl_Tehniks.ID_Tehniks = tbl_Current_Tehniks.ID_Tehniks) INNER JOIN tbl_Okazanie_Uslug ON tbl_Tehniks.ID_Tehniks = tbl_Okazanie_Uslug.ID_Tehniks
WHERE (((tbl_Tehniks.Date_Dawn) Between dIn() And dout()) AND ((tbl_Okazanie_Uslug.ID_Goods)>0))
GROUP BY tbl_Current_Tehniks.ID_Sotrudnik;
qry_Sums
SELECT qry_SumDetIng.SumDet, qry_SumRem.[Sum-Sum_Remonta], qry_SumDetIng.ID_Sotrudnik
FROM qry_SumDetIng INNER JOIN qry_SumRem ON qry_SumDetIng.ID_Sotrudnik = qry_SumRem.ID_Sotrudnik;
- 50%?
.
Public Function dIn() As Date
dIn = Date - Weekday(Date, vbMonday) + 1
End Function
Public Function dOut() As Date
dOut = Date - Weekday(Date, vbMonday) + 6
End Function
...
Private Sub 54_Click()
Dim strSqlSRA As String
Dim strSqlSZA As String
Dim strSqlSD As String
Dim strSqlSN As String
Dim iSD As Integer
Dim iSR As Integer
Dim iSN As Integer
Dim dIn As Date
Dim dOut As Date
Dim rst As ADODB.Recordset
'
dIn = Date - Weekday(Date, vbMonday) + 1
dOut = Date - Weekday(Date, vbMonday) + 6
' ,
strSqlSRA = "SELECT Sum(tbl_Tehniks.Sum_Remonta) AS All_Sum_Remonts FROM tbl_Tehniks " & _
"WHERE tbl_Tehniks.Date_Dawn Between #" & Format(dIn, "mm\/dd\/yy hh\:mm\:ss") & "#" & " AND #" & Format(dOut, "mm\/dd\/yy hh\:mm\:ss") & "# " & _
"And tbl_Tehniks.Otrem = True;"
Set rst = New ADODB.Recordset
rst.Open strSqlSRA, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
iSR = Format(rst.Fields("All_Sum_Remonts"), "fixed")
rst.Close
Set rst = Nothing
Me.fld_All_Sum_Rem = iSR
',
strSqlSD = "SELECT Sum(tbl_Okazanie_Uslug.Price_Det * tbl_Okazanie_Uslug.Qty) AS SumDet " & _
"FROM tbl_Tehniks INNER JOIN tbl_Okazanie_Uslug ON tbl_Tehniks.ID_Tehniks = tbl_Okazanie_Uslug.ID_Tehniks " & _
"WHERE tbl_Tehniks.Date_Dawn Between #" & Format(dIn, "mm\/dd\/yy hh\:mm\:ss") & "#" & " AND #" & Format(dOut, "mm\/dd\/yy hh\:mm\:ss") & "# " & _
"And tbl_Tehniks.Otrem = True;"
Set rst = New ADODB.Recordset
rst.Open strSqlSD, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
iSD = Format(rst.Fields("SumDet"), "fixed")
rst.Close
Set rst = Nothing
MsgBox iSD
' ,
strSqlSN = "SELECT Sum(([tbl_tovary].[price_naz]-[tbl_tovary].[price_tov])*[tbl_okazanie_uslug].[qty]) AS [SumNac]" & _
"FROM tbl_Tehniks INNER JOIN (tbl_Tovary INNER JOIN tbl_Okazanie_Uslug ON tbl_Tovary.Id_Tovar = tbl_Okazanie_Uslug.ID_Goods) ON tbl_Tehniks.ID_Tehniks = tbl_Okazanie_Uslug.ID_Tehniks " & _
"WHERE tbl_Tehniks.Date_Dawn Between #" & Format(dIn, "mm\/dd\/yy hh\:mm\:ss") & "#" & " AND #" & Format(dOut, "mm\/dd\/yy hh\:mm\:ss") & "#;"
Set rst = New ADODB.Recordset
rst.Open strSqlSN, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
iSN = Format(rst.Fields("SumNac"), "fixed")
Me.fld_Pribyl = iSN
MsgBox " ..."
Exit Sub
',
strSqlSZA = "SELECT Sum(([Sum-Sum_Remonta]-[SumDet])*[Stavka]) AS Zarplata " & _
"FROM (tbl_Sotrudniki RIGHT JOIN (qry_Sum_Rem_Ingeners LEFT JOIN qry_Sum_Detali_Ingeners " & _
"ON qry_Sum_Rem_Ingeners.First_Name = qry_Sum_Detali_Ingeners.Sotrudnik) " & _
"ON tbl_Sotrudniki.First_Name = qry_Sum_Detali_Ingeners.Sotrudnik) LEFT JOIN qry_Sum_Avans " & _
"ON tbl_Sotrudniki.ID_Sotrudnik = qry_Sum_Avans.ID_Sotrudnik;"
Set rst = New ADODB.Recordset
rst.Open strSqlSZA, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
MsgBox rst.Fields("Zarplata")
rst.Close
Set rst = Nothing
End Sub
? , "".
http://www.sql.ru/forum/1216969/funkciya-na-obnovlenie-procenta-v-tablice