C
Cyberwolf
This can get really frustrating. I have the following code. When I execute
case 1 it works fine, it deletes the old data and imports the new. If I try
to execute any of the other cases I get Error 2391 stating that a field does
not exist in the destination table. The field is diffrent for each case so I
am thinking it is picking up the excel spreadsheet from case 1 and trying to
import it into the other table.
the code is:
Private Sub butImpStoreInfo_Click()
'On Error GoTo butImpStoreInfo_Click_Err
Dim stTableName As String
Dim stDocName As String
Select Case optStoreImp
Case 1
stDocName = "G:\Accounting\AR\AR Database\walmart stores.xls"
DoCmd.OpenQuery "qry:WalMartStoreDel", acViewNormal, acEdit
DoCmd.TransferSpreadsheet acImport, , "WalmartStores", stDocName, True,
WalMartStores
Case 2
stDocName = "G:\Accounting\AR\AR Database\walmart stores.xls"
DoCmd.OpenQuery "qry:WalMartDCMailDel", acViewNormal, acEdit
DoCmd.TransferSpreadsheet acImport, , "WalmartDCMail", stDocName, True,
WalMartDCMailing
Case 3
stDocName = "G:\Accounting\AR\AR Database\walmart stores.xls"
DoCmd.OpenQuery "qry:WalMartDCRecDel", acViewNormal, acEdit
DoCmd.TransferSpreadsheet acImport, , "WalmartDCRec", stDocName, True,
WalMartDCReceiving
Case 4
stDocName = "G:\Accounting\AR\AR Database\walmart stores.xls"
DoCmd.OpenQuery "qry:SamsClubsDel", acViewNormal, acEdit
DoCmd.TransferSpreadsheet acImport, , "SamsClubs", stDocName, True, SamsClubs
Case 5
stDocName = "G:\Accounting\AR\AR Database\walmart stores.xls"
DoCmd.OpenQuery "qry:SamsDCRecDel", acViewNormal, acEdit
DoCmd.TransferSpreadsheet acImport, , "SamsDCRec", stDocName, True,
SamsDCReceiving
End Select
'butImpStoreInfo_Click_Exit:
' Exit Sub
'butImpStoreInfo_Crick_Err:
' MsgBox Err.Description
' Resume butImpStoreInfo_Click_Exit
End Sub
case 1 it works fine, it deletes the old data and imports the new. If I try
to execute any of the other cases I get Error 2391 stating that a field does
not exist in the destination table. The field is diffrent for each case so I
am thinking it is picking up the excel spreadsheet from case 1 and trying to
import it into the other table.
the code is:
Private Sub butImpStoreInfo_Click()
'On Error GoTo butImpStoreInfo_Click_Err
Dim stTableName As String
Dim stDocName As String
Select Case optStoreImp
Case 1
stDocName = "G:\Accounting\AR\AR Database\walmart stores.xls"
DoCmd.OpenQuery "qry:WalMartStoreDel", acViewNormal, acEdit
DoCmd.TransferSpreadsheet acImport, , "WalmartStores", stDocName, True,
WalMartStores
Case 2
stDocName = "G:\Accounting\AR\AR Database\walmart stores.xls"
DoCmd.OpenQuery "qry:WalMartDCMailDel", acViewNormal, acEdit
DoCmd.TransferSpreadsheet acImport, , "WalmartDCMail", stDocName, True,
WalMartDCMailing
Case 3
stDocName = "G:\Accounting\AR\AR Database\walmart stores.xls"
DoCmd.OpenQuery "qry:WalMartDCRecDel", acViewNormal, acEdit
DoCmd.TransferSpreadsheet acImport, , "WalmartDCRec", stDocName, True,
WalMartDCReceiving
Case 4
stDocName = "G:\Accounting\AR\AR Database\walmart stores.xls"
DoCmd.OpenQuery "qry:SamsClubsDel", acViewNormal, acEdit
DoCmd.TransferSpreadsheet acImport, , "SamsClubs", stDocName, True, SamsClubs
Case 5
stDocName = "G:\Accounting\AR\AR Database\walmart stores.xls"
DoCmd.OpenQuery "qry:SamsDCRecDel", acViewNormal, acEdit
DoCmd.TransferSpreadsheet acImport, , "SamsDCRec", stDocName, True,
SamsDCReceiving
End Select
'butImpStoreInfo_Click_Exit:
' Exit Sub
'butImpStoreInfo_Crick_Err:
' MsgBox Err.Description
' Resume butImpStoreInfo_Click_Exit
End Sub