I am using this command
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblSales_YTD", strFileName, True, Worksheet & "!"
where Worksheet is the name of a Worksheet on an Excel spreadsheet which is importing into the Database. The user puts the name of the worksheet they want imported into the Text Box but without the space at the end the Worksheet cannot be found. The Excel spreadsheet is coming from a 3rd party and they have labeled the worksheet with a space at the end. I guess I could get the user to rename the Worksheet in Excel and remove the space however I am trying to make the process as simple as possible. I could also add the space permanantly as has been suggested b y doing this
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblSales_YTD", strFileName, True, Worksheet & " !" (Added space before the !)
however if the 3rd party decides to remove the space later on I will have to modify the code. I want the user to be able to type the worksheet name as its presented to them. I can do this using an input Box instead of the Text box however they then need to type the worksheet name everytime they import. My problem would be resolved if the text box would store the space.
Thanks All.