SubForm NOT moving to next record (1 Viewer)

Peter Bellamy

Registered User.
Local time
Today, 01:22
Joined
Dec 3, 2005
Messages
295
I want to stop moving to the next record when leaving the last control on a subform.
I plan to build a simple message box giving the choice between allowing the move or moving the focus to a control on the open record.

Just setting the focus where I want it does not accomplish it, it still opens a new record.

Cheers
 

boblarson

Smeghead
Local time
Yesterday, 17:22
Joined
Jan 12, 2001
Messages
32,059
Set the Cycle property of the form to be CURRENT RECORD.
 

Peter Bellamy

Registered User.
Local time
Today, 01:22
Joined
Dec 3, 2005
Messages
295
Thanks Bob, I knew there was a control in there somewhere!

peter
 

Peter Bellamy

Registered User.
Local time
Today, 01:22
Joined
Dec 3, 2005
Messages
295
Thought I'd fixed this but it is still opening a new record even when NO is chosen.
Can someone point out my mistake.........please.

Code:
Private Sub goods_notes_Enter()

L = 1
Debug.Print "Notes Entry", L, Me.Cycle

End Sub

Private Sub goods_notes_Exit(Cancel As Integer)
On Error GoTo err_goods_notes

Dim response As Integer
Debug.Print "Notes Exit, L , cycle", L, Me.Cycle
If L = 1 Then

 'choose if new record or additional part form required
response = MsgBox("Add another part to this Return?", 292, "Part or New Return")
    If response = 7 Then ' No chosen
       Me.Cycle = 1
       Forms![Return record].[Goods Data].Form.[goods_notes].SetFocus
       Debug.Print "Notes Exit No chosen", L, Me.Cycle
    Else
        Me.Cycle = 0
        Debug.Print "Notes Exit Yes chosen", L, Me.Cycle
    End If

End If
L = 0
Exit_goods_notes:
Exit Sub

L is dimensioned in Declarations, it acts as a flag to stop the the question being asked as records are being stepped through but to use it if goods_notes has had the focus

pnb
 

Users who are viewing this thread

Top Bottom