PDA

View Full Version : Updated Record Field has Wrong Data on Subsequent SELECT



Mavila
06-21-2018, 10:27 AM
I have a record that I'm UPDATING like so:

num = 9

cmdTypeUpdate = "UPDATE [Classes] SET [Type] = '2', [Legal Duration] = '" & num & "' WHERE [ID] = '" & cmb.ListIndex & "'

cn.execute (cmdTypeUpdate)

That works - it updates the record with the appropriate values.

However, the macro then goes on to refresh a listbox with a SELECT statement, like so:

lstSELECT = "SELECT [ClassNm], [Legal Duration], [Policy Duration] FROM [Classes]"

and the value for myrecordset.fields(1) is not 9, but is always 0. If I stop/reset the macro, then the SELECT statement works fine retrieving 9 from the field in the database.

Any ideas what may be going on here? Thank you.

Mavila
06-21-2018, 01:36 PM
Well, I can't figure this behavior out, but I found a work-around which is to Unload the UserForm and then call it again. This works but it's not optimal since the UserForm flickers. But, I don't have any other solutions.

OBP
06-23-2018, 04:16 AM
You can use
me.requery
to update the form or
me.listboxnamehere.requery
to upate just the list box.