aziz rasul
Active member
- Local time
- Today, 22:11
- Joined
- Jun 26, 2000
- Messages
- 1,935
I have a spreadsheet, which I have no control over, that typically has worksheet names like
Ireland
UK
etc.
The UK example has spaces before and after.
I have the worksheet names in a table. I'm trying to create a DoCmd.TransferSpreadsheet statement which will import all the worksheets in to their respectives tables. Here's what I have so far.
Do While Not rstCountry.EOF
CurrentDb.Execute "DELETE * FROM tblConsolidatedInvoices" & rstCountry!country & "Temp;"
CurrentDb.Execute "DELETE * FROM tblConsolidatedInvoices" & rstCountry!country & ";"
' DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblConsolidatedInvoices" & rstCountry!country & "Temp", txtFilepath, False, "' UK !'"
' DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblConsolidatedInvoices" & rstCountry!country & "Temp", txtFilepath, False, "Ireland!"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblConsolidatedInvoices" & rstCountry!country & "Temp", txtFilepath, False, rstCountry!countryname & "!"
rstCountry.MoveNext
Loop
I can get it to work for Ireland but not for " UK ". I can get them both to work individually (see the commented code) but I need them to work thru the recordset.
Ireland
UK
etc.
The UK example has spaces before and after.
I have the worksheet names in a table. I'm trying to create a DoCmd.TransferSpreadsheet statement which will import all the worksheets in to their respectives tables. Here's what I have so far.
Do While Not rstCountry.EOF
CurrentDb.Execute "DELETE * FROM tblConsolidatedInvoices" & rstCountry!country & "Temp;"
CurrentDb.Execute "DELETE * FROM tblConsolidatedInvoices" & rstCountry!country & ";"
' DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblConsolidatedInvoices" & rstCountry!country & "Temp", txtFilepath, False, "' UK !'"
' DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblConsolidatedInvoices" & rstCountry!country & "Temp", txtFilepath, False, "Ireland!"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblConsolidatedInvoices" & rstCountry!country & "Temp", txtFilepath, False, rstCountry!countryname & "!"
rstCountry.MoveNext
Loop
I can get it to work for Ireland but not for " UK ". I can get them both to work individually (see the commented code) but I need them to work thru the recordset.