19 בנוב׳ 2023, 22:54

@גבאי
כשכתבתי את הקוד בזמנו התבקשתי ליצור גיבוי לטבלה הקיימת ולעשות ייבוא לטבלה חדשה
אם אתה רוצה שזה יכנס לאותה טבלה ניתן לעשות במקום זה פעולת מחיקה של הנתונים בטבלה לפני הייבוא
בצורה כזו אתה יכול להגדיר את הגדרות השדות של הטבלה, לכאורה זה אמור לפתור את הבעיה, אם לא צריך להגדיר מפרט ייבוא ספציפי עבור הטבלה שלך
להלן הקוד עם התיקון לייבוא לאותה הטבלה:

Function importListAllInformation()
 
strtoken = "0770000000:1234"
Set xhrRequest = CreateObject("Msxml2.ServerXMLHTTP.6.0")
sURL = "https://www.call2all.co.il/ym/api/DownloadFile?token=" & strtoken & "&path=ivr/EnterID/ListAllInformation.ini"
 
xhrRequest.Open "GET", sURL, False
xhrRequest.Send
       
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write xhrRequest.ResponseBody
DoEvents
 
filePath = CurrentProject.Path & "\ListAllInformation.txt"
If Len(Dir(filePath)) Then Kill filePath
oStream.SaveToFile filePath
oStream.Close
 
filePath = CurrentProject.Path & "\ListAllInformation.txt"
DoCmd.SetWarnings False
 
TableIsExists = Not IsNull(DLookup("Name", "MSysObjects", "type in(1,6) and Name='ListAllInformation'"))
If TableIsExists Then  DoCmd.RunSQL "DELETE * FROM ListAllInformation"
DoCmd.TransferText acImportDelim, "", "ListAllInformation", filePath, True, , 65001
Kill filePath
MsgBox "בוצע בהצלחה", vbInformation, "בוצע"
 
End Function