VBA code to append data (1 Viewer)

Ossama22

Registered User.
Local time
Today, 22:56
Joined
Aug 31, 2018
Messages
52
Hello guys ,
Could you please help me about if there any VBA code to append data from excel to access , i mean i have a table linked to form i need a button when i press on it all the data in excel file (in a specific destination in my pc) appended to this table , is that possible.
 

Ranman256

Well-known member
Local time
Today, 15:56
Joined
Apr 9, 2015
Messages
4,339
append query.
either link the xl file as an external table then run append query
or
run the transfer :
docmd.TransferSpreadsheet acImport ,acSpreadsheetTypeExcel12,sTable, sFile, true,sSheetName
 

Ossama22

Registered User.
Local time
Today, 22:56
Joined
Aug 31, 2018
Messages
52
I follow the steps , but i dont know where’s the mistake , could you help plz ?
 

Attachments

  • 7B22EA5D-DBA7-4FF7-87BB-A443B63B6B10.jpg
    7B22EA5D-DBA7-4FF7-87BB-A443B63B6B10.jpg
    129.2 KB · Views: 65

isladogs

MVP / VIP
Local time
Today, 20:56
Joined
Jan 14, 2017
Messages
18,209
That's giving me eye strain looking at your photo

Please use the print screen button to get a legible image, crop to what is needed then upload
 

Ossama22

Registered User.
Local time
Today, 22:56
Joined
Aug 31, 2018
Messages
52
Iam sorry about the previous pic , here’s the screenshot
 

Attachments

  • A2966A95-9AC0-4FC1-9F6F-DE5C3595B317.png
    A2966A95-9AC0-4FC1-9F6F-DE5C3595B317.png
    4.8 KB · Views: 78

isladogs

MVP / VIP
Local time
Today, 20:56
Joined
Jan 14, 2017
Messages
18,209
You need quote marks around the table name, file name and range arguments.
 

Ossama22

Registered User.
Local time
Today, 22:56
Joined
Aug 31, 2018
Messages
52
Iam sorry for being annoying, but iam still face some problems 😔
 

Attachments

  • EB21533F-64DB-4573-B696-634CA6479810.png
    EB21533F-64DB-4573-B696-634CA6479810.png
    5.8 KB · Views: 61

isladogs

MVP / VIP
Local time
Today, 20:56
Joined
Jan 14, 2017
Messages
18,209
Unless you tell us what problems, we can't help.

BTW it's even easier to copy and paste the code here using the code tags # button in the reply.
 

Ossama22

Registered User.
Local time
Today, 22:56
Joined
Aug 31, 2018
Messages
52
Private Sub Command197_Click()
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "Copy Of Refernce", "N:\001 ALL FORM2", True, "Adding new", ""
End Sub
 

isladogs

MVP / VIP
Local time
Today, 20:56
Joined
Jan 14, 2017
Messages
18,209
Ok you copied the code though didn't use the code tag button.
What's the problem?

EDIT: The final part , "" does nothing and should be removed
 
Last edited:

Users who are viewing this thread

Top Bottom