+ Reply to Thread
Results 1 to 6 of 6

Transfer sheet method on files with date extension

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Transfer sheet method on files with date extension

    Hello everyone. I would like to transfer an Excel spreadsheet into an Access table using the TransferSheet Method. The caveat is that the name of the file needs to involve a variable (a date) based on an entry from a TextBox.

    The name of the table is tblMTMReportData. It already has column headings. The name of the Excel spreadsheets is as follows: mtm_report_asof_yyyymmdd.xls. Now the date extension "yyyymmdd" varies.

    Now I have created a userform and on that userform is a TextBox and a Command Button. The textbox is called txtDate. The command button is called CommandReturnMTMPortfolio.

    What I would like to happen is for the user to enter a date say 20110419. After that the user presses the button and the macro(or code) retrieves the file based on the date extension. The path to the files and folders are contained in another table.

    I am getting an error on the variable I call Dim asofDATE As String, it says that it is undefined? Any suggestions. If there is a neater cleaner way to get this done let me know.

    The code I have so far is below:

    Please Login or Register  to view this content.
    Last edited by AnthonyWB; 05-17-2011 at 11:21 AM. Reason: New error after fixing

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,855

    Re: Transfer sheet method on files with date extension

    Try changing this line
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

    Alan
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Transfer sheet method on files with date extension

    Thanks for the reply. That is not working either. Note that txtDate is being highlighted in yellowas Undefined.
    Last edited by AnthonyWB; 05-17-2011 at 09:31 AM. Reason: word correction

  4. #4
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Transfer sheet method on files with date extension

    I should also not that the code in the post above is written in a module and not on the userfrom, the code for the command button is on the userform.


    Please Login or Register  to view this content.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,855

    Re: Transfer sheet method on files with date extension

    I'm guessing here, but maybe have to identify the form that the text box is located on, ie. Forms!YourFormName.txtDate.Text

    It is possible that Access does not know where to go to find txtDate Control and needs some help.

    Alan

  6. #6
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Transfer sheet method on files with date extension

    So this helps:

    Please Login or Register  to view this content.
    I now get a new error:

    Object variable or with block variable not set.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1