ongke0711 > 07-07-18, 12:04 AM
(06-07-18, 11:02 PM)thanhtruong Đã viết: Còn cái số lượng nữa, phải thêm thế nào
ví dụ : X072 SL 1, X073 SL 2.
phải sửa code ở chổ nào ạ.
Function GopDong2(TenField1CanGop As String, TenField2CanGop As String, TenFieldThamChieu As String, FieldThamChieu As Variant, TenTable As String)
'Ham dung de gop các dong co chung mot truong (field) nao do lai voi nhau.'
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim RowList As String
Set db = CurrentDb()
strSQL = "SELECT " & TenField1CanGop & "," & TenField2CanGop & " FROM " & TenTable & " WHERE CStr([" & TenFieldThamChieu & "])=""" & FieldThamChieu & """"
Debug.Print strSQL
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If Not rs.EOF Then
rs.MoveFirst
End If
Do While Not rs.EOF
RowList = RowList & rs(0) & " SL " & rs(1) & "; "
rs.MoveNext
Loop
GopDong2 = Left(RowList, Len(RowList) - 2)
End Function