Results 1 to 5 of 5
  1. #1
    CodeUnkown is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    3

    AddNew not working

    I have the following code and it doesn't throw any errors but does nothing. I'm sure I'm missing something minor but just can't figure it out and have searched different solutions with no avail...



    Code:
    Dim db As DatabaseDim rs As Recordset
    
    
    Set db = CurrentDb
    Set rs = CurrentDb.OpenRecordset("tblSales")
    With rs
        rs.AddNew
         rs!Desc = Me.txtDesc.Value
         rs!Item = Me.txtItem.Value
         rsPost_Price = txtPosted.Value
         rs!Sell_Price = txtSold.Value
         rs!Sold_Loc = txtChannel.Value
        rs.Update
    End With
    rs.Close

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    rsPost_Price is missing ! character

    But that alone should not prevent record getting created.

    The Dim statements are running together but I am guessing they are not actually like that in your code.
    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
    CodeUnkown is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    3
    I fixed the missing character and yes, the dim statements are separated (on new lines) within my code. Ive used this statement before and idk why it isn't working now.

  4. #4
    CodeUnkown is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    3
    Newbie mistake, had the table up and open instead of opening it after the statement was executed .... facepalm big time.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Does not prevent my code adding record. Maybe Office365 is different.
    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.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. AddNew Function, but with Criteria?
    By mrmims in forum Modules
    Replies: 2
    Last Post: 03-20-2017, 05:44 PM
  2. Recordset readonly on rs.addnew
    By Ruegen in forum Programming
    Replies: 5
    Last Post: 02-04-2015, 08:29 PM
  3. Error on AddNew to an empty recordset
    By kowalski in forum Programming
    Replies: 7
    Last Post: 05-22-2013, 06:17 PM
  4. Using Recordset rst.AddNew
    By dandoescode in forum Programming
    Replies: 1
    Last Post: 06-06-2012, 10:10 AM
  5. How to code in AddNew Button In Access DBA
    By ganeshvenkatram in forum Access
    Replies: 0
    Last Post: 07-07-2011, 02:50 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