Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    fjbrad is offline Novice
    Windows 11 Office 365
    Join Date
    Mar 2025
    Posts
    6

    Table update order

    I write a new record into a table then update it in code then start another process which queries the aforementioned table. However the table has not been updated and only seems to do so after the entire procedure has been completed. How can I force the table to be updated?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    How do you "write a new record into a table"?
    Show your code so we can see what is happening.
    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    fjbrad is offline Novice
    Windows 11 Office 365
    Join Date
    Mar 2025
    Posts
    6
    Quote Originally Posted by June7 View Post
    How do you "write a new record into a table"?
    Show your code so we can see what is happening.
    If you want to provide db for analysis, follow instructions at bottom of my post.
    The offending code segment is:
    foo = DLookup("[filename]", "Publish Names", "[recipeid] = " & recRecipe![recipeid])
    Set recPublish = curDb.OpenRecordset("Publish Names")
    If IsNull(foo) Then
    recPublish.AddNew
    recPublish![recipeid] = recRecipe![recipeid]
    Else
    recPublish.Edit
    End If
    recPublish![recipename] = recRecipe![recipename]
    recPublish![filename] = strPublishName
    On Error GoTo 0
    recPublish.Update
    recPublish.Close

    I'm wondering if I ought to just put it in a separate function and call it from this location. Following this code is some housekeeping and calls to two other procedures to write other HTML pages which currently do not reflect the addition made here.

    Set recPreferences = curDb.OpenRecordset("preferences")
    recPreferences.Edit
    recPreferences!LastPublish = intLastDate
    recPreferences.Update
    recPreferences.Close
    Set curDb = Nothing
    If Me!PublishToWeb = "Web" Then
    foo = WriteMenu()
    foo = WriteRecipeList()
    MsgBox strPublishName & vbCrLf & "Ready to upload", vbOKOnly, "Recipe Publish"
    Call Shell("C:\Program Files\FileZilla FTP Client\filezilla.exe", 1)
    Else
    MsgBox strPublishName & vbCrLf & "available for local viewing", vbOKOnly, "Recipe Publish"
    End If

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2021
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    Don't see how your code got beyond the first line, not to mention the second.
    The record source (table or query) contains a space. It must be "[Publish Names]"

  5. #5
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    opening a recordset on table with space does not need to put the
    table name in bracket.

    you only put bracket on Query or using Domain function.

  6. #6
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    if the OP is working on the form, then after Closing recPublish,
    he needs to Requery the Form's recordset:

    Code:
    ..
    ..
    recPublish.Update
    recPublish.Close
    [Forms]![YourFormName].Recordset.Requery 
    
    'if the code is on the same form, use
    'Me.Recordset.Requery

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Weird fact: brackets are not required for table/query name in domain aggregate function, even if there is space or punctuation/symbol. For field name, yes need brackets. So, OP's code is legit in that regard.

    Also, if the OpenRecordset were using SQL statement, would need brackets.

    Advise not to use spaces nor punctuation/special characters (underscore only exception) in naming convention.

    fjbrad, note for future - please put code between CODE tags to retain indentation and readability. Click # icon on edit menu. Might be able to still edit your post.

    Why are you using code to create/edit record? Are you not using BOUND form?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    I note there is a ‘on error GoTo 0’ line which implies error checking has been turned off in code not shown. OP needs to comment out ‘on error resume next’ or step through the code checking values line by line to ensure they are what is expected until the issue is resolved

  9. #9
    fjbrad is offline Novice
    Windows 11 Office 365
    Join Date
    Mar 2025
    Posts
    6

    go to 0 code

    Quote Originally Posted by CJ_London View Post
    I note there is a ‘on error GoTo 0’ line which implies error checking has been turned off in code not shown. OP needs to comment out ‘on error resume next’ or step through the code checking values line by line to ensure they are what is expected until the issue is resolved
    The presence of error handlers are an indication of sloppy housekeeping. The code was checked long ago but this is a round toit project and the annoyance of having to click the publish routine button twice has only recently become annoying enough to warrant attention

  10. #10
    fjbrad is offline Novice
    Windows 11 Office 365
    Join Date
    Mar 2025
    Posts
    6
    This routine doesn't alter any of the 4 tables shown on the form so I don't think this would apply.

  11. #11
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    Quote Originally Posted by fjbrad View Post
    This routine doesn't alter any of the 4 tables shown on the form so I don't think this would apply.
    so the tables in your form are not the one being updated?
    then what is the problem if it need to complete the whole process before your table get updated?

  12. #12
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    565
    Never mind all the code nonsense. Please explain what you're trying to accomplish in more detail.

    How are you "updating the record in code"? Do you do something silly like open a recordset and never issue .Edit and .Update statements? Is there a reason you're using a recordset for this?

    You can force the record to be updated using VBA and use .Update method of the recordset. I guess if you're doing one record at a time, it's not terrible. But if you're doing bulk updates, just use queries instead.

  13. #13
    fjbrad is offline Novice
    Windows 11 Office 365
    Join Date
    Mar 2025
    Posts
    6
    Quote Originally Posted by madpiet View Post
    Never mind all the code nonsense. Please explain what you're trying to accomplish in more detail.

    How are you "updating the record in code"? Do you do something silly like open a recordset and never issue .Edit and .Update statements? Is there a reason you're using a recordset for this?

    You can force the record to be updated using VBA and use .Update method of the recordset. I guess if you're doing one record at a time, it's not terrible. But if you're doing bulk updates, just use queries instead.
    The routine writes a hypertext recipe file from four tables. When that completes it writes recipe name, index number, and publish name into the Publish Names table. It then calls two other routines which write hypertext lookup files but they do not have the current recipe included as it hasn't been written into the Publis Name table. I can just run it twice but that screws up my created/modified date.

  14. #14
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    565
    Quote Originally Posted by fjbrad View Post
    The routine writes a hypertext recipe file from four tables. When that completes it writes recipe name, index number, and publish name into the Publish Names table. It then calls two other routines which write hypertext lookup files but they do not have the current recipe included as it hasn't been written into the Publis Name table. I can just run it twice but that screws up my created/modified date.
    "writes a hypertext recipe from 4 tables" - can't you just use q query for that?
    Maybe you could land it in a temporary table/tempdb (Except Abscess doesn't have those).

    If all but the first writing shouldn't happen, then just check for the existence of that recipe or whatever in the final table before writing it again. (Yikes, I'm starting to sound like Aaron what's-his-face!)

    I guess you'd have to use DCOUNT() to search the recipe table for a given recipe (so you use the recipe name or ID in the filter), and if it's zero, then you insert the record. otherwise you don't. Then you won't get multiple inserts for the same recipe on the same day.

  15. #15
    fjbrad is offline Novice
    Windows 11 Office 365
    Join Date
    Mar 2025
    Posts
    6
    Quote Originally Posted by madpiet View Post
    "writes a hypertext recipe from 4 tables" - can't you just use q query for that?
    Maybe you could land it in a temporary table/tempdb (Except Abscess doesn't have those).

    If all but the first writing shouldn't happen, then just check for the existence of that recipe or whatever in the final table before writing it again. (Yikes, I'm starting to sound like Aaron what's-his-face!)

    I guess you'd have to use DCOUNT() to search the recipe table for a given recipe (so you use the recipe name or ID in the filter), and if it's zero, then you insert the record. otherwise you don't. Then you won't get multiple inserts for the same recipe on the same day.
    The process of creating the HTML file begins thusly:
    Print #intFileNum, " </head>"
    Print #intFileNum, " <body itemscope itemtype=" & Chr(34) & "http://schema.org/Recipe" & Chr(34) & ">"
    Print #intFileNum, " <div class=" & Chr(34) & "fullpage" & Chr(34) & ">"
    Print #intFileNum, " <p class=" & Chr(34) & "breadcrumb" & Chr(34) & ">YOU ARE HERE: <a href=" & Chr(34) & "index.html" & Chr(34) & " target=" & Chr(34) & "_top" & Chr(34) & ">Home</a> > <a href=" & Chr(34) & "recipe.html" & Chr(34) & " target=" & Chr(34) & "_top" & Chr(34) & ">My Recipes</a> > " & strShowName & " <a href=" & Chr(34) & "" & strFileName & "" & Chr(34) & " target=" & Chr(34) & "_new" & Chr(34) & ">print version</a></p>"
    Print #intFileNum, " <div class=" & Chr(34) & "titlebar" & Chr(34) & ">"
    Print #intFileNum, " <h2><span itemprop=" & Chr(34) & "Name" & Chr(34) & ">" & strShowName & "</span></h2>"
    If Nz(recRecipe![author]) = "" Or Nz(recRecipe![source]) = "" Then
    strSource = Nz(recRecipe![author]) & " " & Nz(recRecipe![source])
    Else
    strSource = Nz(recRecipe![author]) & " @ " & Nz(recRecipe![source])
    End If

    I'm reasonably sure that a query won't cut it.

    At any rate I have resolved the problem by removing the offending code to private function and calling it from the same place in the code followed by calls to the code to write the menus.
    Thanks to all for your suggestions.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 03-07-2016, 05:02 PM
  2. Replies: 3
    Last Post: 02-09-2016, 04:36 PM
  3. Replies: 23
    Last Post: 09-14-2015, 01:34 PM
  4. Allow more than order in an ORDER form.
    By kiko in forum Access
    Replies: 37
    Last Post: 04-19-2013, 05:30 AM
  5. How to order columns in ascending order?
    By darkingthereturn in forum Access
    Replies: 5
    Last Post: 06-18-2012, 05:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums