Link to home
Start Free TrialLog in
Avatar of sami_hamad
sami_hamad

asked on

import from excel /

i want to import some rows (cells) from excel ,
but without repeating the same row ,
i used this code its working very gut ,,
how i can check before import that some record already exist !!
thnaks

hier my code

on click
    Dim oXL As Object
    Dim oWs As Object
    Dim rs As DAO.Recordset
    Dim i As Integer

    Set oXL = CreateObject("Excel.Application")
    Set oWs = oXL.Workbooks.Open("C:\Users\User1\Desktop\booking.xlsx")

    Set rs = CurrentDb.OpenRecordset("booking")
    zeile = 2
      
    Dim Ende As Long
    Ende = 0

    Do Until oWs.workSheets("booking").Cells(Ende + 2, 2) = ""
        Ende = Ende + 1
    Loop
 
    MsgBox "TRANSFER DONE"
    With rs
        For i = 1 To Ende
            .AddNew
               
            .Fields("Date of Tour") = oWs.workSheets("booking").Cells(zeile, 6)
            .Fields("Pickup Time") = oWs.workSheets("booking").Cells(zeile, 7)
            .Fields("name of account") = oWs.workSheets("booking").Cells(zeile, 3)
            .Fields("Tour") = oWs.workSheets("booking").Cells(zeile, 5)
            .Fields("Pax AD") = oWs.workSheets("booking").Cells(zeile, 8)
            .Fields("Pax ch") = oWs.workSheets("booking").Cells(zeile, 9)
            .Fields("cost AD") = oWs.workSheets("booking").Cells(zeile, 10)
            .Fields("cost ch") = oWs.workSheets("booking").Cells(zeile, 11)
            .Fields("sale AD") = oWs.workSheets("booking").Cells(zeile, 12)
            .Fields("sale ch") = oWs.workSheets("booking").Cells(zeile, 13)
            .Fields("PaymentMeth") = oWs.workSheets("booking").Cells(zeile, 15)
            .Fields("Driver") = oWs.workSheets("booking").Cells(zeile, 16)
            .Fields("Guide") = oWs.workSheets("booking").Cells(zeile, 17)
            .Fields("TotalCollect") = oWs.workSheets("booking").Cells(zeile, 18)
            .Fields("bookedby") = oWs.workSheets("booking").Cells(zeile, 20)
            .Fields("mob") = oWs.workSheets("booking").Cells(zeile, 21)
            .Fields("pickupfrom") = oWs.workSheets("booking").Cells(zeile, 22)
            .Fields("Guset Name") = oWs.workSheets("booking").Cells(zeile, 23)
            .Fields("others") = oWs.workSheets("booking").Cells(zeile, 24)
            .Fields("provider") = oWs.workSheets("booking").Cells(zeile, 26)
            .Fields("language") = oWs.workSheets("booking").Cells(zeile, 28)
            .Fields("e mail") = oWs.workSheets("booking").Cells(zeile, 29)
       
            .Update
            
            zeile = zeile + 1
            DoEvents
        Next i
        .Close
    End With
    Set rs = Nothing
        
    oWs.Close
    oXL.Quit
    Set oWs = Nothing
    Set oXL = Nothing
    DoCmd.Requery

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.