|
本帖最后由 todaynew 于 2011-11-11 21:36 编辑
Function zpl(BH As String) As String
Dim 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 |
|