X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> How To Check Eof And Commit Edited Record, Access 2016    
post Aug 13 2019, 06:14 AM

Posts: 41
Joined: 23-January 19

Hi everyone.
Got a split database application/split form (datasheet on lower half) that is shared by 8 users. They are analyzing their department setups. When complete they check a box called MGR_APPRV_READY. This check is to qualify an update. I found in this form the record would not commit so I put an acNext and acPrevious to invoke a save record. The acCmdSave did not commit, only to the move next and return would set the record. When user is on their last record the acNext throws a error.
Below is my attempt to check if last record and close and reopen form committing the edited record. I appreciate your help and time.

Private Sub MGR_APPRV_READY_Click()
Dim rs As String
DoCmd.RunCommand acCmdSave

If Not rs.EOF Then
DoCmd.GoToRecord , , acNext
DoCmd.GoToRecord , , acPrevious
DoCmd.OpenForm "team_librarianTAXONOMYWorkbench"
End If
End Sub
Go to the top of the page
post Aug 13 2019, 06:43 AM

UtterAccess VIP
Posts: 7,971
Joined: 24-May 10
From: Downeast Maine

To clarify, do you mean the database is split into separate front end and back end files, and each user has their own copy of the front end? If not, that's what it should be.

If you are clicking a command button on a form that displays a record you are not at EOF. Despite the name, EOF (end of file, I think) does not mean the last record, but rather the condition of attempting to move past the last record. BOF is similar in concept, except at the beginning of the recordset.

Do you have Option Explicit at the top of the code module? If so (or in any case) does the code compile? You have designated rs as a string, but you are using it as if it is a recordset variable. Either way, you never set it to anything.

I use Me.Dirty = False to save a record, but for DoCmd I think the command is acCmdSaveRecord. I believe acCmdSave saves design changes to the object, although if so I don't understand why or if it would be used during runtime.

With Me.Dirty some people do:
If Me.Dirty Then
    Me.Dirty = False
End If

I don't see the value of checking for Me.Dirty first, so I just use Me.Dirty = False

Going to the next record saves the record because that is how Access works. However, there is no need for that. You can save the record in place.

It doesn't look like your code will ever close the form and open another one, because at the time of clicking the command button you will never be at EOF. As an FYI, you can always close the current form with:

DoCmd.Close acForm, Me.Name

Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    21st October 2019 - 03:17 PM