感谢符鸿敏版主的指点.你的方法非常的简单好用.
我后来又想到了另外一种方法即用点燃一支烟版主推荐的思路实现了,在此十分感谢两位版主的及张老师的帮助.
我也将我的方法贴出来和大家共亨:
代码如下:
Dim sm, ch, sm1, ch1, mindate, maxdate, datefw As String
Dim hh As Integer
Dim strSQL As String
Dim rst1, rst2 As DAO.Recordset
strSQL = "SELECT 2.SENSORID, 2.Badgenumber, 2.日期列表 FROM 2 ORDER BY 2.Badgenumber,2.SENSORID "
Set rst1 = CurrentDb.OpenRecordset(strSQL)
If rst1.EOF Or rst1.BOF Then Exit Sub
Do Until rst1.EOF
strSQL = ""
strSQL = "SELECT 1.Badgenumber, 1.SENSORID, 1.日期 FROM 1 " & _
"WHERE ((1.Badgenumber = '" & rst1("badgenumber") & "') AND (1.SENSORID = '" & rst1("SENSORID") & "')) " & _
"ORDER BY 1.Badgenumber, 1.SENSORID"
Set rst2 = CurrentDb.OpenRecordset(strSQL)
sm = "": ch = ""
Do Until rst2.EOF
ch = Day(rst2("日期"))
sm = sm & ch & ","
rst2.MoveNext
Loop
CurrentDb.Execute "UPDATE 1 LEFT JOIN 2 ON ([1].Badgenumber = [2].Badgenumber) AND ([1].SENSORID = [2].SENSORID) SET [2].日期列表 = '" & sm & "'" & _
"WHERE ((1.Badgenumber = '" & rst1("badgenumber") & "') AND (1.SENSORID = '" & rst1("SENSORID") & "')) "
rst1.MoveNext
Loop
rst1.Close
Set rst1 = Nothing
rst2.Close
Set rst2 = Nothing
附件可用三楼的附件.