Office中国论坛/Access中国论坛

标题: 请问如何将子表的单号字断用&合并,如:单号汇总的内容为:P00001&200801554 [打印本页]

作者: 真主    时间: 2009-7-24 10:12
标题: 请问如何将子表的单号字断用&合并,如:单号汇总的内容为:P00001&200801554
请问如何将子表的单号字断用&合并,如:单号汇总的内容为:P00001&200801554
作者: Henry D. Sy    时间: 2009-7-24 10:27
Private Sub Form_Current()
    Dim rs As New ADODB.Recordset
    Dim strSQL As String
    Dim temp As String
    strSQL = "select 单号 from 表2 where 所属主表ID=" & Me.ID
    With rs
        .Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
        Do While Not .EOF
            temp = temp & .Fields(0) & "&"
            .MoveNext
        Loop
        .Close
    End With
    Set rs = Nothing
    If Len(temp) <> 0 Then
        temp = Left(temp, Len(temp) - 1)
    End If
    Me.单号汇总 = temp
End Sub
作者: 真主    时间: 2009-7-24 10:39
谢谢Henry D. Sy




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3