Results 1 to 5 of 5
  1. #1
    barks1981 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    3

    Object Required When Importing

    Hi All,

    I'm new to this forum and am just convert a database to Access 2003, most things have worked once converted all but import code for importing external data.

    I have the following code assign to an button on the main menu form.

    Code:
     
    Private Sub Command49_Click()
    On Error GoTo Command49_Click_Err
                Name "\\gbw607sc0080\everyone\system spares\WCS\data\WCS_406P_" & Text12.Value As "\\gbw607sc0080\everyone\system spares\WCS\data\WCS_406P_" & Text12.Value.txt
                
                DoCmd.TransferText acImportDelim, "dataimport2", "Master Data", "\\gbw607sc0080\everyone\system spares\WCS\data\WCS_406P_" & Text12.Value.txt, False, ""
                
                MsgBox ("WCS data File Succesfully Imported!")
                DoCmd.RunMacro ("Append_Update")
                DoCmd.Requery
                List59.Requery
                retrievalschart.Requery
                manstchart.Requery
                Exceptchart.Requery
                checkinlineschart.Requery
                checkinsrchart.Requery
                checkinitemschart.Requery
                PutawayChart.Requery
                DZMovesProd.Requery
                DZMoves.Requery
                WDLP.Requery
                WDLP1.Requery
                Storage.Requery
                MPutaway.Requery
                Retrievals.Requery
                NormalOmit.Requery
                langlicence.Requery
                langprod.Requery
                LangSR.Requery
                LangLines.Requery
                LangItems.Requery
                
    Command49_Click_Exit:
        Exit Sub
    Command49_Click_Err:
        MsgBox Error$
        Resume Command49_Click_Exit
    End Sub
    When clicking the button i get the following message appear

    Object required

    Not sure whats missing but think it could be the code thats highlighted red cause if i change this to the correct name it works fine. I have a text box of the form which i what it to use to complete the filename as the file name is always WCS_406P_yyyymmdd which is what is in the text box.

    Any help on this would be fantastic.

    Thanks

    Dave

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    The post is messed up and not displaying lines with the url string properly. Post just those lines but with a space between the double slashes so the site won't try to turn your string into a URL link and I can then tell what's yours.

    What I think you need is for this: & Text12.Value.txt

    to be: & Text12.Value & ".txt"
    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
    barks1981 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    3
    Private Sub Command49_Click()
    On Error GoTo Command49_Click_Err
    Name "\ \gbw607sc0080\everyone\system spares\WCS\data\WCS_406P_&Text12.Value&" As "\ \gbw607sc0080\everyone\system spares\WCS\data\WCS_406P_ &Text12.Value&.txt"

    DoCmd.TransferText acImportDelim, "dataimport2", "Master Data", "\ \gbw607sc0080\everyone\system spares\WCS\data\WCS_406P_ &Text12.Value&.txt", False, ""

    MsgBox ("WCS data File Succesfully Imported!")
    DoCmd.RunMacro ("Append_Update")
    DoCmd.Requery
    List59.Requery
    retrievalschart.Requery
    manstchart.Requery
    Exceptchart.Requery
    checkinlineschart.Requery
    checkinsrchart.Requery
    checkinitemschart.Requery
    PutawayChart.Requery
    DZMovesProd.Requery
    DZMoves.Requery
    WDLP.Requery
    WDLP1.Requery
    Storage.Requery
    MPutaway.Requery
    Retrievals.Requery
    NormalOmit.Requery
    langlicence.Requery
    langprod.Requery
    LangSR.Requery
    LangLines.Requery
    LangItems.Requery

    Command49_Click_Exit:
    Exit Sub
    Command49_Click_Err:
    MsgBox Error$
    Resume Command49_Click_Exit
    End Sub

    Have added the space between so that it doesn't come up as a url.

    Thanks

    Dave

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Try changing

    "\ \gbw607sc0080\everyone\system spares\WCS\data\WCS_406P_&Text12.Value&.txt", False, ""

    to

    "\ \gbw607sc0080\everyone\system spares\WCS\data\WCS_406P_" & Text12.Value & ".txt", False
    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
    barks1981 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    3
    Fixed the issue for the object required then had the issue that it wouldn't find the file, code below is how i managed to get it working.


    Private Sub Command49_Click()
    On Error GoTo Command49_Click_Err
    Dim datecount1 As Integer
    Dim DateCapture As String
    Dim mypath As String
    Dim mydate As String
    Dim myfile As String
    mypath = "\ \gbw607sc0080\everyone\system spares\WCS\data\WCS_406P_"
    mydate = Text12.Value
    myfile = mypath & mydate & ".txt"
    DateCapture = Text12.Value
    datecount1 = dcount("[date]", "import date", "[date] = " & DateCapture)

    If datecount1 > 0 Then
    MsgBox ("File Already Imported!")
    Else
    Name mypath & mydate As myfile

    DoCmd.TransferText acImportDelim, "dataimport2", "Master Data", myfile, False, ""

    MsgBox ("WCS data File Succesfully Imported!")
    DoCmd.RunMacro ("Append_Update")
    DoCmd.Requery
    List59.Requery
    retrievalschart.Requery
    manstchart.Requery
    Exceptchart.Requery
    checkinlineschart.Requery
    checkinsrchart.Requery
    checkinitemschart.Requery
    PutawayChart.Requery
    DZMovesProd.Requery
    DZMoves.Requery
    WDLP.Requery
    WDLP1.Requery
    Storage.Requery
    MPutaway.Requery
    Retrievals.Requery
    NormalOmit.Requery
    langlicence.Requery
    langprod.Requery
    LangSR.Requery
    LangLines.Requery
    LangItems.Requery

    Command49_Click_Exit:
    Exit Sub
    Command49_Click_Err:
    MsgBox Error$
    Resume Command49_Click_Exit

    End If
    End Sub

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

Similar Threads

  1. Error: Object Required
    By compooper in forum Programming
    Replies: 6
    Last Post: 06-22-2011, 07:52 AM
  2. Object Required Error.
    By Robeen in forum Forms
    Replies: 1
    Last Post: 03-28-2011, 10:30 AM
  3. Replies: 1
    Last Post: 08-05-2010, 12:11 PM
  4. Run-time error '424': Object required
    By cowboy in forum Programming
    Replies: 18
    Last Post: 07-07-2010, 03:32 PM
  5. Object required
    By duckie10 in forum Access
    Replies: 1
    Last Post: 05-15-2009, 02:11 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