Solved If Yes/No Box clicked to update data and exit form else to go to next record.

angekap

New member
Local time
Today, 15:18
Joined
Mar 16, 2021
Messages
12
Hi Everone
I have a form and have a Yes/No Box in it.

What I want to do is I have entered an Event Procedure On Exit where if I have the Yes clicked I want to update the data and exit the form else if it not clicked to go to the next record on the form. I tried the following code:

Private Sub NOTPAID_Exit(Cancel As Integer)

If ([NOTPAID] = "YES") Then
Me.Update
Close
Else

DoCmd.GoToRecord , , acNext

End If

End Sub

....but it does not work ....can anyone help...Thanks !!!!
 
Last edited:
Try:
Code:
Private Sub NOTPAID_Exit(Cancel As Integer)

    If ([NOTPAID] = True) Then
        Me.Dirty = False
        Docmd.Close acForm, Me.Name
    Else

        DoCmd.GoToRecord , , acNext

    End If

End Sub
 
Try:
Code:
Private Sub NOTPAID_Exit(Cancel As Integer)

    If ([NOTPAID] = True) Then
        Me.Dirty = False
        Docmd.Close acForm, Me.Name
    Else

        DoCmd.GoToRecord , , acNext

    End If

End Sub
Hi I tried it and it gets stuck on the line

DoCmd.GoToRecord , , acNext

Do I have to insert something in that line ??
 
Replace it with:
DoCmd.RunCommand acCmdRecordsGoToNext
 
Replace it with:
DoCmd.RunCommand acCmdRecordsGoToNext
Hi Again..Slowly getting There in Debug it is yellowing now this line

DoCmd.Close acForm, Me.NAME

The form's name is DAYUSE should I replace it the Me.NAME with Me.DAYUSE ?
 
you can also use Other events:
Code:
Private Sub Form_Current()
    If Me.NOTPAID Then
        DoCmd.GoToRecord , , acNext
    End If
End Sub

Private Sub NOTPAID_Click()
    Me.Dirty = False
   If Me.NOTPAID Then
       Call Form_Current
   Else
       DoCmd.Close acForm, Me.Name
   End If
End Sub
 
you can also use Other events:
Code:
Private Sub Form_Current()
    If Me.NOTPAID Then
        DoCmd.GoToRecord , , acNext
    End If
End Sub

Private Sub NOTPAID_Click()
    Me.Dirty = False
   If Me.NOTPAID Then
       Call Form_Current
   Else
       DoCmd.Close acForm, Me.Name
   End If
End Sub
Hi Thanks That code worked fine !!
 

Users who are viewing this thread

Back
Top Bottom