|
本帖最后由 koutx 于 2009-11-13 17:37 编辑
建一空白查询,将下面红色Sql代码贴进去:
SELECT jindu.编号, jindu.位置, pl([编号],[位置]) AS 序号
FROM jindu
GROUP BY jindu.编号, jindu.位置;
照下面代码建一模块函数
Function pl(bh As String, wz As String) As String
Dim str As String
str = "SELECT jindu.* FROM jindu WHERE jindu.编号 = '" & bh & "' AND jindu.位置 = '" & wz & "'"
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
pl = ""
rs.Open str, CurrentProject.Connection, adOpenStatic, adLockBatchOptimistic rs.MoveFirst
For j = 1 To rs.RecordCount
If rs.Fields("编号") = bh And rs.Fields("位置") = wz Then
pl = pl & rs.Fields("序号") & ","
End If
rs.MoveNext
Next
pl = Left(pl, Len(pl) - 1)
End Function
查询效果如下图示:
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|