Results 1 to 5 of 5
  1. #1
    thart21 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    83

    Choose Import Spec from option group

    Hey there,

    Is there a way to run DoCmd.TransferText and run a different Import Spec based on a user selection from an option group on a form? I can set it up to run a specific spec but do not see an argument for a "Where" option.

    Private Sub Command17_Click()
    Dim strfileName As String
    strSpec = "Import-RDS"
    strfileName = "\\Path\UnshipRDS.txt"
    DoCmd.TransferText , strSpec, "Unship RDS", strfileName, Yes
    End Sub



    Ideally, I would love to have just one Import Spec with a variable using the same option group/form but from my searches don't see how that is possible using the automated Import spec process in Access.


    Thanks!

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Let's say you have an option group with the options that have the values 0, 1, 2. You could do this:

    Code:
    Private Sub Command17_Click()
    Dim strfileName As String
     
    Select Case Me.OptionGroupFrameNameHere
       Case 0
          trSpec = "Import-RDS"
       Case 1
          trSpec = "Import-XXX"
       Case 2
          trSpec = "Import-SomethingElse"
    End Select
    
    strfileName = "\\Path\UnshipRDS.txt"
    
    DoCmd.TransferText , strSpec, "Unship RDS", strfileName, True
    
    End Sub
    By the way that should be TRUE at the end of your TransferText line, not yes.

  3. #3
    thart21 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    83
    Thanks Bob! Regarding the strfileName path, how do I tell it which .txt file I want imported? Do I even need that argument if it is running the Import spec?

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    You should be able to use code for a file dialog. I'll try to post instructions as soon as I can. Got an issue at work right now.

  5. #5
    thart21 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    83
    Hi Bob, I got it to work using this:

    strfileName = optText.Value
    strMyVariable = "\\MyPath\Current Data\" & strfileName & ""
    DoCmd.TransferText , strSpec, "Unships", strMyVariable, True

    When the user selects an option, I have it populate optText and use that to tell it what actual text file name to pull. Thanks for all of your help! Toni

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

Similar Threads

  1. Option group and date
    By kigor in forum Forms
    Replies: 0
    Last Post: 04-22-2011, 12:52 AM
  2. Option Group - Borders are gone
    By cevatyildiz in forum Forms
    Replies: 0
    Last Post: 04-30-2010, 06:08 AM
  3. Option Group
    By huskies in forum Forms
    Replies: 9
    Last Post: 12-02-2009, 12:06 PM
  4. no option to import xls file or option all files
    By captgnvr in forum Import/Export Data
    Replies: 3
    Last Post: 09-22-2009, 10:19 AM
  5. option group in form
    By mawa4492 in forum Forms
    Replies: 1
    Last Post: 08-05-2009, 02:49 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