Why sometimes the record set opening system in Ms Access Fail to update data (1 Viewer)

nector

Member
Local time
Today, 09:46
Joined
Jan 21, 2020
Messages
346
I'm getting puzzled on the code below , see if you can spot why this code fail to save data on the table sometimes in Ms Access and how should I do force it ensure all the received from Json is saved not left blank. Quite ok 99% of data received as a block is saved but sometime it return blank or empty , what could be the cause of this?

Code:
Set db = CurrentDb
Set Rs = db.OpenRecordset("ESDdReceipts", dbOpenDynaset)
    Set json = JsonConverter.ParseJson(strDataAudit)
   
    'Process data.
    Z = 1
    For Each Details In json
        Rs.AddNew
        Rs![ESDTime] = CDate(Format$(Details("ESDTime"), "00/00/00 00:00:00"))
        Rs![TerminalID] = Details("TerminalID")
        Rs![InvoiceCode] = Details("InvoiceCode")
        Rs![InvoiceNumber] = Details("InvoiceNumber")
        Rs![FiscalCode] = Details("FiscalCode")
        Rs![SerialNumber] = Me.txtEsDFinInvoice
        Rs.Update
        Z = 1 + 1
    Next
 
    Rs.Close
    Set Rs = Nothing
    Set db = Nothing
    Set json = Nothing
    Set Details = Nothing
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:46
Joined
Oct 29, 2018
Messages
21,358
Maybe the JSON file contains blanks?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 02:46
Joined
Feb 28, 2001
Messages
27,001
I'm with theDBguy on this one. Syntactically and semantically, I see no errors. I would have to say this is a data condition, not a code condition. You MIGHT consider that before you do the Rs.Update, you do a "sanity check" to see if one or more key fields is blank, and to not do the update if your sanity check fails. Other than that, I would look to the incoming data.
 

Users who are viewing this thread

Top Bottom