Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Hi Hendrick!



    The MyImportsDrive() function, just replace the drive of the path of your saved imports, doesn't execute them.

    With your button, you just need to execute the saved import-export like bellow:
    Code:
    CurrentProject.ImportExportSpecifications.item("Import-tblSynonymsADD").Execute
    (for the first saved import)

    and
    Code:
    CurrentProject.ImportExportSpecifications.item("Import-Blokkiesadd").Execute
    (for the second saved import)

    or with a generic procedure like this:
    Code:
    Sub ExecuteMyImports()
        Dim IES As ImportExportSpecification
    
        For Each IES In CurrentProject.ImportExportSpecifications
            With CurrentProject.ImportExportSpecifications
                Select Case MsgBox("Do you want to execute the '" & IES.Name & "' saved import-export specification?", vbQuestion + vbYesNoCancel)
                    Case vbCancel
                        'Abort any next execution.
                        Exit For
                    Case vbYes
                        'Execute current saved import-export spec and step to the next.
                        IES.Execute
                    Case Else
                        'Abort the execution of the current saved import-export spec and step to the next.
                End Select
            End With
        Next IES
    End Sub
    Put it in a code module (if you like in the same module with the MyImportsDrive() function), and then, you can call it via your button(s) as seems bellow:
    Code:
    Private Sub btnmake_sintbl_Click()
        Call ExecuteMyImports 
    End Sub
    I hope it helps.

    Cheers,
    John
    Last edited by accesstos; 09-16-2019 at 08:08 AM. Reason: Procedure name correction (Call ExecuteMyImports)

  2. #17
    hendrikbez is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    138
    John

    Thank you again for your help, I understand now what you are doing. It is working

    Thank you for all that have treid to help me.

  3. #18
    hendrikbez is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    138
    John

    I must have something wrong or do not understand this.

    I have make the import files at work. When I press the button it is working.
    Import-tblSynonymsADD

    Click image for larger version. 

Name:	Screenshot - 2019_09_16 , 14_42_25.png 
Views:	11 
Size:	5.2 KB 
ID:	39740


    Import-blokikiesADD

    but when I try to run it at home, with the same button it give me this error
    Click image for larger version. 

Name:	Screenshot - 2019_09_16 , 14_43_55.png 
Views:	11 
Size:	5.7 KB 
ID:	39741

  4. #19
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Hi Hendrik!

    As you can see, the path of the saved import still refers to "D:" drive.

    Did you replace the "MyHomeComputer" of MyImportsDrive() function with the actual name of your home computer?
    If you did and the path of the saved imports are still on "D:" drive, then something doesn't working. Check the code of the "On Load" event of your form that opens first.

    Do you see the messagebox that informs you for the drive of the saved imports and the name of the computer when you open the Access file from your home computer? If you do, what you see?

  5. #20
    hendrikbez is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    138
    Quote Originally Posted by accesstos View Post
    Hi Hendrik!

    As you can see, the path of the saved import still refers to "D:" drive.

    Did you replace the "MyHomeComputer" of MyImportsDrive() function with the actual name of your home computer?
    If you did and the path of the saved imports are still on "D:" drive, then something doesn't working. Check the code of the "On Load" event of your form that opens first.

    Do you see the messagebox that informs you for the drive of the saved imports and the name of the computer when you open the Access file from your home computer? If you do, what you see?
    Here is my code, I have put it in code in module1

    Code:
    Function MyImportsDrive() As String
        Dim IES As ImportExportSpecification
        Dim strDrive As String
    
        If Environ("computername") = "Hendrik" Then
            strDrive = "c:\"
            For Each IES In CurrentProject.ImportExportSpecifications
                IES.XML = Replace(IES.XML, "d:\", strDrive)
            Next IES
        Else
            strDrive = "d:\"
            For Each IES In CurrentProject.ImportExportSpecifications
                IES.XML = Replace(IES.XML, "c:\", strDrive)
            Next IES
        End If
        MyImportsDrive = strDrive
    End Function
    and when I start the access file, it does show the computer name and drive.

    Click image for larger version. 

Name:	Screenshot - 2019_09_16 , 16_28_37.png 
Views:	12 
Size:	3.9 KB 
ID:	39742
    Code:
    Option Compare Database
    Private Sub Form_Load()
    MsgBox "Jy is nou aangeteken op rekenaar " & Environ("computername") _
               & " en nou sal jou saved imports werk op " _
               & MyImportsDrive & " drive.", vbInformation
    End Sub

  6. #21
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    And you are still getting the same error message when you try to execute the saved import?
    In "Saved Imports" window, are the paths still on "D:" drive?

    Set one brake point on the line of MsgBox in Form_Load() code and run step by step the code (F8) to see what happens.

  7. #22
    hendrikbez is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    138
    Hi John

    My Bad, my error, I did have a different path on my home pc, so I have changed it to the same path on home pc now, and it is now working.

  8. #23
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Tricky field formats in excel imports
    By tonygg in forum Access
    Replies: 3
    Last Post: 10-13-2015, 02:23 PM
  2. Access 2010 Saved Imports
    By Tomfernandez1 in forum Access
    Replies: 1
    Last Post: 09-27-2011, 12:27 PM
  3. Need Frequent Excel Imports with Primary Keys
    By UMassEngineer in forum Import/Export Data
    Replies: 1
    Last Post: 03-27-2011, 10:07 AM
  4. Adding a 0 to single digit imports
    By TheWolfster in forum Access
    Replies: 6
    Last Post: 02-16-2010, 05:19 PM
  5. Tab Delimited Imports
    By SandyDandy in forum Import/Export Data
    Replies: 1
    Last Post: 02-20-2009, 08:53 AM

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