Private Sub cmdRevertXTab_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("Staging")
Dim g(100) As String
Dim n As Integer
n = rs.Fields.Count - 1
For i = 2 To rs.Fields.Count - 1
g(i) = rs(i).Name
Next
DoCmd.SetWarnings off
DoCmd.RunSQL "Delete * from Desired"
For i = 2 To n
rs.MoveFirst
Do While Not (rs.EOF) '
sql = "Insert into Desired Values ('" & g(i) & "', '" & rs(1) & "','" & Nz(rs(i), "0") & "')"
DoCmd.RunSQL sql
rs.MoveNext
Loop
Next i
DoCmd.SetWarnings True
End Sub
|