Consulting

Results 1 to 3 of 3

Thread: Updated Record Field has Wrong Data on Subsequent SELECT

  1. #1
    VBAX Contributor
    Joined
    Aug 2012
    Posts
    120
    Location

    Updated Record Field has Wrong Data on Subsequent SELECT

    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.

  2. #2
    VBAX Contributor
    Joined
    Aug 2012
    Posts
    120
    Location
    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.

  3. #3
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    You can use
    me.requery
    to update the form or
    me.listboxnamehere.requery
    to upate just the list box.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •