NguyenDungAnh > 26-09-18, 05:49 PM
Private Sub cmdphongthi_Click()
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
Dim phong, tongsophong, b, c, i As Integer
Dim s, s1, s2, a As String
phong = 0
Set rs1 = CurrentDb.OpenRecordset("select * from tblmamon")
rs1.MoveFirst
Do While Not rs1.EOF
Set rs2 = CurrentDb.OpenRecordset("select * from tbx where Mamon = '" & rs1!mamon & "';")
rs2.MoveLast
'sophongdunguoi = Int(rs2.RecordCount / 24) - 1
'songuoicondu = rs2.RecordCount - 24 * a
'If songuoicondu Mod 2 = 1 Then 'tinh so nguoi 2 phong cuoi
tongsophong = Int(rs2.RecordCount / 24) + 1
rs2.MoveFirst
a = "1"
i = 1
Do While Not rs2.EOF
On Error GoTo abc
phong = phong + 1
stt = 0
If i = tongsophong Then
b = rs2.RecordCount - 24 * (i - 1)
Else
b = 24
i = i + 1
End If
For j = 1 To b
If rs2.Fields("khuvuc") <> a Then
Debug.Print "doi khu vuc"
j = 1
stt = 0
phong = phong + 1
tongsophong = tongsophong + 1
a = rs2.Fields("khuvuc")
End If
stt = stt + 1
Debug.Print stt
rs2.Edit
rs2!phong = phong
rs2!stt = stt
rs2.Update
rs2.MoveNext
Next
abc: rs2.MoveLast
Loop
rs1.MoveNext
Loop
End Sub
NguyenDungAnh > 26-09-18, 05:50 PM
duynamvnn1208 > 26-09-18, 08:57 PM
NguyenDungAnh > 26-09-18, 09:20 PM
NguyenDungAnh > 26-09-18, 09:55 PM
NguyenDungAnh > 26-09-18, 10:38 PM
ongke0711 > 27-09-18, 12:13 AM
(26-09-18, 10:38 PM)NguyenDungAnh Đã viết: https://drive.google.com/open?id=1pTXUy4...NLnTbu5kNM
sau một tối dày công suy nghĩ tốn bao nhiêu cafe và thuốc lá cũng nghĩ ra )
NguyenDungAnh > 27-09-18, 07:45 AM
NguyenDungAnh > 27-09-18, 08:27 AM
NguyenDungAnh > 27-09-18, 09:31 AM