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

angekap

New member
Local time
Today, 10:51
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:

bob fitz

AWF VIP
Local time
Today, 08:51
Joined
May 23, 2011
Messages
4,719
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
 

angekap

New member
Local time
Today, 10:51
Joined
Mar 16, 2021
Messages
12
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 ??
 

bob fitz

AWF VIP
Local time
Today, 08:51
Joined
May 23, 2011
Messages
4,719
Replace it with:
DoCmd.RunCommand acCmdRecordsGoToNext
 

angekap

New member
Local time
Today, 10:51
Joined
Mar 16, 2021
Messages
12
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 ?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:51
Joined
May 7, 2009
Messages
19,232
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
 

angekap

New member
Local time
Today, 10:51
Joined
Mar 16, 2021
Messages
12
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

Top Bottom