Results 1 to 11 of 11
  1. #1
    dimitrijus99 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2020
    Posts
    13

    Post Mistery in macro code

    Hi,

    I have excel and accsess connection through macro. When launching macro in excel he taking destination from excel going to accsess and based on destination import data to accses database agregate it and return back and refresh excel file.
    I get this whole excel and accsess from last employee and now start strugling with code. We had change one of the report and additionally add one column. After that change I added one line in data table with same name as in Excel, but data not going there and at all data are wrong after we change this report (in excel).
    I found that there are line in code: DoCmd.TransferText acImportDelim, "Agents_Daily_ImportSpec", "TBL_Agents_Daily", strfolder & "" & strFileName
    If I undesrtand it correct there are Agent_Daily_ImportSpec table or something where are described what data from excel to accsess table should go. But problem is that I couldn't find this table or settings anywhere. Maybe you have ideas where it could be of course if I understood code correct?

    That's the whole part for this import action:
    Case "Agents Daily"
    'Check if file has already been imported
    If DCount("Filename", "TBL_Agents_Daily_ImportedFiles", "Filename=""" & strFileName & """") = 0 Then
    DoCmd.TransferText acImportDelim, "Agents_Daily_ImportSpec", "TBL_Agents_Daily", strfolder & "" & strFileName
    CurrentDb.Execute "INSERT INTO TBL_Agents_Daily_ImportedFiles (Filename) " & vbCrLf & _
    "VALUES('" & strFileName & "')"
    strDateFile = Replace(strFileName, "Agents_Daily_", "")
    strDateFile = Replace(strDateFile, ".csv", "")
    dt_datefile = Mid(strDateFile, 5, 2) & "/" & Right(strDateFile, 2) & "/" & Left(strDateFile, 4)


    SQLquery = "UPDATE TBL_Agents_Daily SET [Start - Date]=#" & dt_datefile & "# WHERE [Start - Date]IS NULL"
    CurrentDb.Execute SQLquery
    icounter_new = icounter_new + 1
    strLastFileImported = strFileName
    strLastFileImportedDate = Format(Now, "dd/MM/yyyy")
    Else
    icounter_existing = icounter_existing + 1
    End If
    'Debug.Print strFileName

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Agents_Daily_ImportSpec is not a table, it is an import specification - a set of parameters import wizard will use.

    An import specification can be created first time an import operation is done manually. Save the specification then it will be available for future reference in subsequent imports of same source.

    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    dimitrijus99 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2020
    Posts
    13
    If I took this file from previous user who was creator and couldn't now contact with him, how I could find those import specification and where I could find them?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    On External Data tab there are buttons "Saved Imports" and "Saved Exports".
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    dimitrijus99 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2020
    Posts
    13
    It's empty. There aren't those information about import. Export also empty. Other ideas?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Import/Export specifications are in a hidden system table. Can query that table:

    SELECT MSysIMEXSpecs.* FROM MSysIMEXSpecs;

    My table shows 3 records but nothing listed in I/E dialog.
    If they no longer show in the I/E dialog, I have no idea how to recover. I don't really use specifications.

    I expect will have to build new spec yourself as I already described.


    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    dimitrijus99 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2020
    Posts
    13
    Find it. But there are just table, without column names. When I tried change column name in database it's showing me error message that system couldn't find those column name. Doe's somwhere there are described column names also?

    DateDelim DateFourDigitYear DateLeadingZeros DateOrder DecimalPoint FieldSeparator FileType SpecID SpecName SpecType StartRow TextDelim TimeDelim
    / 0 0 0
     0 26
    0 1  :
    . -1 -1 0 , ; 437 13 Agents_Daily_ImportSpec 1 1
    :
    . -1 -1 0 , ; 1257 22 Info_Daily_ImportSpec 1 0
    :
    . -1 -1 0 , ; 1252 10 KLAC_CDR_Daily_20200301 Import Specification 1 1 " :
    . -1 -1 0 , ; 1252 11 KLAC_CDR_ImportSpec 1 1 " :

  8. #8
    dimitrijus99 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2020
    Posts
    13
    There are also relationship between some uknown tables for me.

    Click image for larger version. 

Name:	Capture11.PNG 
Views:	11 
Size:	17.1 KB 
ID:	42306

  9. #9
    dimitrijus99 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2020
    Posts
    13
    Find it!
    Instead of SELECT MSysIMEXSpecs.* FROM MSysIMEXSpecs; I wrote SELECT MSysIMEXColumns.* FROM MSysIMEXColumns; and find described columns with specID. Change information there. Only one problem that in report was 54 columns and new one was added in the middle of report, so had recalculate START and WIDHT values
    Thank you for help

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Congratulations for figuring that out. I learned something new too.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    dimitrijus99 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2020
    Posts
    13
    Thank you for help
    Also I think this could be useful for others

    Click image for larger version. 

Name:	3.PNG 
Views:	11 
Size:	97.7 KB 
ID:	42307

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Can I run a VBA code from a macro?
    By geotrouvetout67 in forum Programming
    Replies: 4
    Last Post: 08-22-2019, 02:59 PM
  2. Macro Code Help
    By Chris12 in forum Access
    Replies: 4
    Last Post: 05-28-2019, 11:09 AM
  3. Help with NPV Macro Code in VBA
    By BigNasty in forum Macros
    Replies: 6
    Last Post: 11-21-2016, 10:39 PM
  4. VBA code or Access Macro
    By CSGabriel in forum Access
    Replies: 1
    Last Post: 07-27-2012, 09:08 AM
  5. VBA code/Macro help please.
    By Davidyam in forum Access
    Replies: 1
    Last Post: 02-26-2012, 09:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums