GhostofDoom
02-02-2020, 03:45 AM
Hello,
i was wondering how we can check with our code if the date already exist if so we want to ignore it
and still creating the other values
Set ws = ThisWorkbook.Sheets("Sheet5")
ws.Activate
Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.Path & "\Database.ACCDB" & ";Jet OLEDB:Database Password='12345';Mode=Share Exclusive"
Set rs = New ADODB.Recordset
rs.Open "TBL_ImportList", cn, adOpenKeyset, adLockOptimistic, adCmdTable
r = 9 ' 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("m_datetime") = Range("F" & r).value
.Update ' stores the new record
End With
r = r + 1 ' next row
Loop
i was wondering how we can check with our code if the date already exist if so we want to ignore it
and still creating the other values
Set ws = ThisWorkbook.Sheets("Sheet5")
ws.Activate
Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.Path & "\Database.ACCDB" & ";Jet OLEDB:Database Password='12345';Mode=Share Exclusive"
Set rs = New ADODB.Recordset
rs.Open "TBL_ImportList", cn, adOpenKeyset, adLockOptimistic, adCmdTable
r = 9 ' 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("m_datetime") = Range("F" & r).value
.Update ' stores the new record
End With
r = r + 1 ' next row
Loop