+ Reply to Thread
Results 1 to 1 of 1

Thread: Problem with string and date variables.

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

    Problem with string and date variables.

    Hello everyone.

    I am trying to pass a date (short date entered into a textbox) into a string expression that is used to create a file path. What's at issue is the following piece of code:

    strFullFileName = strFilePrefix & Format(asofDATE, "yyyymmdd") & ".xls"
    The variable strFullFileName reads empty. So basically it shows up as
    strFullFileName = " "
    in the immediate window. Now everything else: strFilePrefix and Format(asofDATE, "yyyymmdd") is fine, that is acccording to the immediate window they have the correct values.

    Below is a larger snapshot of the project. Any suggestions?

    Private Sub cmdReturnMTMPortfolio_Click()
        Dim appXL As Excel.Application
        Dim strFilePath As String
        Dim strFileName As String
        Dim strFilePrefix As String
        Dim strFullFileName As String
        Dim strFile As String
        Dim asofDATE As Date
        Dim strasofDATE As String
        Dim txtDate As TextBox
        Dim wbk As Excel.Workbook
                
        On Error GoTo HandleErr
        strFilePrefix = "mtm_report_asof_"
        strFilePath = "N:\CBI-DEPT\Application Delivery\Assignments and Projects\FCIP Program\Spreadsheet Automation\Product\Excel Automation\Robin\Communication\Portfolio List\"
           
        asofDATE = Me.txtDate.Value
       
        Set appXL = New Excel.Application
        
        strFullFileName = strFilePrefix & Format(asofDATE, "yyyymmdd") & ".xls"
        
        Set wbk = appXL.Workbooks.Open(strFilePath & strFullFileName)
        
        DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "tempMTMReportData", strFilePath & strFullFileName, True, "MTM Detail!"
        DoCmd.OpenQuery "qryCPNamesForMTMDailyReportParentandChild"
    Last edited by AnthonyWB; 05-25-2011 at 10:13 AM.

+ 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.2.0