|
查询有难度.不如就建个bb表吧.用代码解决
Private Sub Command0_Click()
Dim myArray()
Dim rs As New ADODB.Recordset
Dim ia As Integer
Dim ib As Integer
Dim ic As Integer
Dim strSQL As String
rs.Open "aa", CurrentProject.Connection, 3, 1
If rs.RecordCount > 0 Then
ReDim myArray(rs.RecordCount, 1 To 3)
Do While rs.EOF = False
If Nz(rs("a")) <> "" Then
myArray(ia, 1) = rs("a")
ia = ia + 1
End If
If Nz(rs("b")) <> "" Then
myArray(ib, 2) = rs("b")
ib = ib + 1
End If
If Nz(rs("c")) <> "" Then
myArray(ic, 3) = rs("c")
ic = ic + 1
End If
rs.MoveNext
Loop
CurrentDb.Execute "Delete * From bb"
For i = 0 To rs.RecordCount
If myArray(i, 1) <> "" Or myArray(i, 2) <> "" Or myArray(i, 3) <> "" Then
strSQL = "INSERT INTO bb ( a, b, c ) Values ('" & myArray(i, 1) & "','" & myArray(i, 2) & "','" & myArray(i, 3) & "')"
CurrentDb.Execute strSQL
End If
Next i
End If
rs.Close
Set rs = Nothing
DoCmd.OpenTable "bb"
End Sub
|
|