Update after import is not working

ria_arora

Registered User.
Local time
Tomorrow, 04:55
Joined
Jan 22, 2011
Messages
56
I'm trying to update one of the field after loading / importing the data in the table. But somehow that field is not getting updated.

Below is the code I have used for the same.

Code:
            Set objAccess = CreateObject("Access.Application")
            objAccess.OpenCurrentDatabase strCnPDatabaseName, , strCnPDatabasePassword
        
            objAccess.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, _
            strTableName, Input_Dir & "\" & InputFileName1, True, File1Wks1 & "!"
 
            strUpdateSQL = "UPDATE " & strTableName & " SET Last_Updated = '" & gsCurrentDateTime & "' "
            gsCnPDatabase.Execute (strUpdateSQL)

If I run the code in debug mode then column is getting updated but if I run without debug mode then it's not getting updated :confused:

I suspact it might takes sometime to refresh the data after export that's why records are not getting update... Any solution?

Regards
Ria
 
Insert a DoEvents between the two actions to render Access to wait for one action to be completed before continuing with the next.
 
After adding DoEvents my form is not getting opened.

Regards
Ria
 
Don't know what happened.

I created new form and in that DoEvent is working but update is still not working
Code:
            Set objAccess = CreateObject("Access.Application")
            objAccess.OpenCurrentDatabase strCnPDatabaseName, , strCnPDatabasePassword
        
            objAccess.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, _
            strTableName, Input_Dir & "\" & InputFileName1, True, File1Wks1 & "!"
 
            strUpdateSQL = "UPDATE " & strTableName & " SET Last_Updated = '" & gsCurrentDateTime & "' "
            gsCnPDatabase.Execute (strUpdateSQL)
 

Users who are viewing this thread

Back
Top Bottom