Copy from one record to next but do not save

koolwaters

Active Member
Joined
May 16, 2007
Messages
403
I am trying to copy certain fields from one record on a continuous form to the next but I do not want it written to the table until the user clicks save.

Here is the code I am currently using, which writes the record to the Claims table.

Code:
Private Sub cmdAdditionalClaim_Click()
Dim dbs As DAO.Database, rst As DAO.Recordset
Dim F As Form
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Dim stDocName As String
Dim i As Integer

Msg = "Are you sure you want to create a new claim?"
Style = vbYesNo + vbInformation
Title = "Duplicate Claim?"
Response = MsgBox(Msg, Style, Title)

    
    If Response = vbYes Then
        Set dbs = CurrentDb
        Set rst = dbs.OpenRecordset("tblClaim")
        'Set rst = DoCmd.GoToRecord , , acNewRec
        Set rst = Me.RecordsetClone

        Me.Tag = Me![ClaimID]

        With rst
        .AddNew
            !ClaimID = Nz(DMax("[ClaimID ]", "tblClaim"), 0) + 1
(I have all of the other fields listed here)
        .Update
        .Move 0, .LastModified
        End With
        
        Me.Bookmark = rst.Bookmark
        
        End If
End Sub

Any suggestions?

Thanks
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Access automatically saves ... not saving can be tricky. You can, however, use the form BeforeUpdate event to cancel saving. Perhaps a boolean control that is not visible ... if the user clicks the SAVE button, code can fill the value with TRUE. If the value is not filled with True, you could prompt to save

Code:
   '---------------------------------- make sure user wants to save
   if not me.invisible_controlname then
  
      'give the user a message
      If MsgBox("Do you want to save this record", vbYesNo + vbDefaultButton2, "Save Record?") = vbNo  Then
  
      'don't save the record yet
      Cancel = true

      exit sub
   end if

WHERE
invisible_controlname is the NAME of a boolean (checkbox) control

on the AfterUpdate event of the form, set the control value to FALSE
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,749
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top