debauch
10-03-2008, 12:45 PM
Hi, Im using the following code :
Sub DAO_Skill_Upload()
Sheet1.Activate
' exports data from the active worksheet to a table in an Access database
Dim db As Database, rs As Recordset, r As Long
Set db = OpenDatabase("C:\Documents and Settings\xxxx\My Documents\Development\xxx_DB.mdb") '2003 DB
' open the database
Set rs = db.OpenRecordset("LOG", dbOpenTable)
' get all records in a table
r = 1 ' the start row in the worksheet
Do While Len(Range("A" & r).Formula) > 0
' repeat until first empty cell in column A
With rs
.AddNew ' create a new record
.Fields("STAR") = Range("A" & r).Value
.Fields("END") = Range("B" & r).Value
.Fields("ORIG") = Range("C" & r).Value
.Fields("NEW= Range("D" & r).Value
.Fields("DUR") = Range("E" & r).Value
.Fields("USER") = Range("F" & r).Value
.Fields("REVERT") = Range("G" & r).Value
.Fields("REASON") = Range("H" & r).Value
' add more fields if necessary...
.Update ' stores the new record
End With
r = r + 1 ' next row
Loop
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
'Call CountData 'count records loaded
ScreenUpdating = True
End Sub
how can I skip what's in Row 1?
Sub DAO_Skill_Upload()
Sheet1.Activate
' exports data from the active worksheet to a table in an Access database
Dim db As Database, rs As Recordset, r As Long
Set db = OpenDatabase("C:\Documents and Settings\xxxx\My Documents\Development\xxx_DB.mdb") '2003 DB
' open the database
Set rs = db.OpenRecordset("LOG", dbOpenTable)
' get all records in a table
r = 1 ' the start row in the worksheet
Do While Len(Range("A" & r).Formula) > 0
' repeat until first empty cell in column A
With rs
.AddNew ' create a new record
.Fields("STAR") = Range("A" & r).Value
.Fields("END") = Range("B" & r).Value
.Fields("ORIG") = Range("C" & r).Value
.Fields("NEW= Range("D" & r).Value
.Fields("DUR") = Range("E" & r).Value
.Fields("USER") = Range("F" & r).Value
.Fields("REVERT") = Range("G" & r).Value
.Fields("REASON") = Range("H" & r).Value
' add more fields if necessary...
.Update ' stores the new record
End With
r = r + 1 ' next row
Loop
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
'Call CountData 'count records loaded
ScreenUpdating = True
End Sub
how can I skip what's in Row 1?