Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

DAO Recordset Entries in Table Do Not Stay Saved

DAO Recordset Entries in Table Do Not Stay Saved

DAO Recordset Entries in Table Do Not Stay Saved

I am having a continuing problem with Recordsets. I use them to add new records (.AddNew/.Update) and if I step through the code, everything works fine. If I run the code normally, there a numerous times (inconsistently) where my table will not have any of the added records. It seems like I can "avoid" this problem by adding a messagebox before closing, but I don't want the user to have a prompt and have to hit "OK" every time I've added records from a recordset. I'd truly appreciate any thoughts, ideas, etc. that I can try as I think I've tried a bunch (adding doevents, sleeps, moving first/last before closing, etc.) all with mixed results. Here is an example of some code:

Set rsSimilarTable = dbCurrent.OpenRecordset("SELECT * FROM [tbl tblName]", dbOpenDynaset, dbSeeChanges)
While Not (rs.EOF)
With rsSimilarTable
!SalesOrderNumber = rs!SalesOrderNumber
!CustomerNumber = rs!CustomerNumber
!PurchaseOrder = rs!PurchaseOrder
!OrderDate = rs!OrderDate
!Value = rs![Value]
End With
set rsSimilarTable = Nothing
' Exit from function/procedure and looking to use the table

Thanks for your help and input.

RE: DAO Recordset Entries in Table Do Not Stay Saved

I don't know the cause of the issue but I'm curious if insert statements would work. You would need to complete the strSQL and use the appropriate delimiters based on field data type.

CODE --> vba

strSQL = "INSERT INTO [tbl tblName] (SalesOrderNumber, CustomerNumber, " & _
    "PurchaseOrder, OrderDate, Value) " & _
    "VALUES (" & rs!SalesOrderNumber & ",'" & rs!CustomerNumber & "', " & _
    ' etc
    debug.Print strSQL  'take a look at the statement
Currentdb.Execute strSQL, dbFailOnError 

Hook'D on Access
MS Access MVP 2001-2016

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close