Oleg_123 at xuppa.com
Oleg_123 at xuppa.com
Sat Sep 4 18:48:30 CDT 2004
Hey Group, happy holidays fro those of u in US. I am supposed to count the number of columns and based on the result import the data into a table with month names. The last column always contains December Am I on the right track ? This is what I've done so far --- Private Sub Command1_Click() Dim cnn As ADODB.Connection Dim rst1 As New ADODB.Recordset Dim SQL1 As String, SQL2 As String Dim a As Integer 'number of columns Dim b As Integer Dim Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec Set cnn = CurrentProject.Connection SQL1 = "Select * From Hrsqd" rst1.Open SQL1, cnn, adOpenKeyset, adLockOptimistic, adCmdTableDirect a = rst1.Fields.Count 'number of fields b = a - 2 ' number of month fields If b = 6 Then 'Jul - Dec Do Until rst1.EOF Jul = rst1.Fields(3) Aug = rst1.Fields(4) Sep = rst1.Fields(5) Oct = rst1.Fields(6) Nov = rst1.Fields(7) Dec = rst1.Fields(8) Loop End If If b = 5 Then 'Aug - Dec Do Until rst1.EOF Aug = rst1.Fields(3) Sep = rst1.Fields(4) Oct = rst1.Fields(5) Nov = rst1.Fields(6) Dec = rst1.Fields(7) Loop End If If b = 4 Then 'Sep - Dec Do Until rst1.EOF Sep = rst1.Fields(3) Oct = rst1.Fields(4) Nov = rst1.Fields(5) Dec = rst1.Fields(6) Loop End If rst1.Close SQL2 = "INSERT Into HRSQD_Full (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec) Values (" & Jan & "," & Feb & "," & Mar & "," & Apr & "," & May & "," & Jun & "," & Jul & "," & Aug & "," & Sep & "," & Oct & "," & Nov & "," & Dec & ")" MsgBox a End Sub ----------------------------------------- Make Money and Find Love at Finally.com http://www.finally.com/?link=webmail