none
No Current Record Error RRS feed

  • Question

  • I have an Access 2013 form with a check box.  I have three events associated with the check box.  They are included below.  I do not want to allow any edits to the records displayed, so that is why I am using the gotfocus and lost focus events.  I start the form with the StatWaiting Check box unchecked.   There are no records displayed on my form as a result.  The first time I put a check mark in the box, the form updates properly and the desired records are displayed.  If I subsequently remove the check mark, it again does not display any records as is desired.

    However, if I put the check mark back again, I get the following error.  When I click the ok button, the check box updates and the correct records are again displayed.  If I place a breakpoint on the first line of each event, it steps through the code with no error message.  Any ideas on how to eliminate this error and why it occurs?

    Private Sub StatWaiting_GotFocus()

         On Error Resume Next

        Me.AllowEdits = True

    End Sub

     

    Private Sub StatWaiting_LostFocus()

       On Error Resume Next

       Me.AllowEdits = False

    End Sub

     

     

    Private Sub StatWaiting_AfterUpdate()

        On Error Resume Next

        Call UpdCtrlWaiting

        Call UpdateSheetDefaults

        If Me.Recordset.BOF = True Or Me.Recordset.EOF = True Then

            Me.TimerInterval = 0

        Else

            Me.TimerInterval = DLookup("[ScrollInterval]", "UtilityTable") * 1000

        End If

    End Sub

    Tuesday, July 14, 2015 3:33 PM

Answers

  • I started messing around with other form properties and discovered the/a culprit.  This form had its allow additions property set to false.  When I set it to true, then the message stopped coming.  There is one blank record in the detail at this point.  I think this will work, since I have locked all the controls in the detail section, they cannot be edited anyhow.  Not a very elegant solution, but what do you think does it make sense?

    Wednesday, July 15, 2015 1:54 PM

All replies

  • Hi,

    Is that why you have On Error Resume Next? Normally, that is only used if you expect an error to happen. Also, why do you need to use the focus events? Why not set the property in the AfterUpdate event as well? Allow Edits shouldn't have anything to do whether records will show up on your form or not. There must be something else that's doing it.

    Just a thought...

    Tuesday, July 14, 2015 4:00 PM
  • Thanks for the response. 

    Yes, that is why I added the on error statement to see if that would eliminate the error.  I don't expect the error to occur, when it did, I added that to see if that would take me past it.

    After further thought, I decided not to use either focus event.  Instead, I simply locked all the controls in the detail section and enabled editing for the form so I could update the check box.  I still get the error and cannot figure out where it is coming from.

    Tuesday, July 14, 2015 5:40 PM
  • Hi. You might double-check other properties of your form; because as I had said, AllowEdits shouldn't stop the form from displaying existing data. Maybe check the RecordSource, DataEntry, Filter, etc. to make sure you're not actually showing an empty form.
    Tuesday, July 14, 2015 6:43 PM
  • I started messing around with other form properties and discovered the/a culprit.  This form had its allow additions property set to false.  When I set it to true, then the message stopped coming.  There is one blank record in the detail at this point.  I think this will work, since I have locked all the controls in the detail section, they cannot be edited anyhow.  Not a very elegant solution, but what do you think does it make sense?

    Wednesday, July 15, 2015 1:54 PM
  • Hi,

    It's hard to say if it makes sense without knowing or seeing your database. But if you say it works for you, then that's what really matters. You'll get the hang if it eventually. Cheers!

    Wednesday, July 15, 2015 2:00 PM