Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19

Thread: Recordset not updating

  1. #16
    Join Date
    May 2006
    Posts
    407
    Upon receiving your database, I saw that the code you were using was your old code with the one change in it. So I copied out of my post, the new code I sent to you to see why it was not working, but it does work. So, if you would copy the entire Sub from the post that I sent to you, and try it, I really think you will find that it works. I don't know if it is because the database, or the recordset, or whatever is not opened and closed and opened and closed, but left open as it is needed. Or just what about the changes I sent to you is causing the routine to work, but it does. The code I got from you in this last mailing did not work when I tried it. But, as I said before, when I copied in the code I had previously sent to you, and ran that code, the routine works.
    If it does not work after you copy the routine from my last post, then send me the database again, when my code in there so I can see why my code does not work in your database.
    Thanks,
    Vic

  2. #17
    Join Date
    Jan 2006
    Posts
    17
    I've found the problem! Finally! The data format Format(i, "mm/dd/yy") without any single quotes around it but # symbols instead.
    So the original line:

    DoCmd.RunSQL "INSERT INTO [Date]([Date-Date], [Date-valid]) VALUES ('" & Format(i, "dd/mmm/yyyy") & "', TRUE )"

    is now:

    DoCmd.RunSQL "INSERT INTO [Date]([Date-Date], [Date-valid]) VALUES (" & Format(i, "mm/dd/yy") & ", TRUE )"

    Also, rather than having

    Set db = Currentdb
    Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)

    I had to change it to be Set rst = Currentdb.OpenRecordset(strSQL, dbOpenDynaset).

    Don't ask me why but that works pefectly now! Thanks so much for your help anyway Vic. Just thought I'd post this last one in case anybody needs it in future.

  3. #18
    Join Date
    May 2006
    Posts
    407
    I did not see anywhere that you actually tried a copy of the entire Sub. Did you try it and it did not work?

  4. #19
    Join Date
    Jan 2006
    Posts
    17
    I tried it the first time you sent it me and it did not work. It wasn't updated in the last db I sent you cos I just sent you the same one as last time. If you want I'll copy and paste your code in and send you that sample?

Posting Permissions

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