思展软件 发表于:2011-11-11 20:42:03
点击下载此附件
如何实现下面的效果呢?
显示内容像查询1
bianhao 辊序号 辊位置
95506 1.2.3.4 1.2:电雕,2.3:卷管
95507 1.2.3.4.5.6.7 1.2:研磨,3.4:电雕,5.6:镀铬,7:卷管
Function zpl(BH As String) As String
Dim str As String, str1 As String, str2 As String
Dim ssql As String
Dim rs As New ADODB.Recordset
Dim i As Long
ssql = "SELECT * FROM gunjindu WHERE bianhao = '" & BH & "' order by gunxuhao"
rs.Open ssql, CurrentProject.Connection, adOpenStatic, adLockBatchOptimistic
str1 = ""
str2 = rs!gunweizhi.Value
For i = 1 To rs.RecordCount
If str2 = rs!gunweizhi.Value Then
str1 = str1 & rs!gunxuhao.Value & "."
Else
zpl = zpl & Left(str1, Len(str1) - 1) & ":" & str2 & " "
str1 = rs!gunxuhao.Value & "."
str2 = rs!gunweizhi.Value
End If
rs.MoveNext
Next
zpl = zpl & Left(str1, Len(str1) - 1) & ":" & str2 & " "
rs.close: Set rs = Nothing
End Function