Solved Load sub-form and go to new record

donkey9972

Registered User.
Local time
Today, 02:36
Joined
May 18, 2008
Messages
82
Hi again, I have an unbound sub-form. On that sub-form when I click a button it loads a specific form. When that form loads into the sub-form I want it to go to a new record, but the problem is the code I use wants the actual form to be opened, so I am not sure how to write the code for the sub-form.

Code:
    DoCmd.GoToControl "txtDate"
    DoCmd.GoToRecord acForm, "frm_Coversheet", acNewRec

Which this code works fine if it was the actual form I was opening, but since its the sub-form it doesn't work.
 
Ok, I found a way to make what I wanted happen. I used this code and it works exactly how I wanted:

Code:
Dim move As Integer
With Me.NavigationSubform.Form.Recordset
        move = .RecordCount
    If move > 0 Then
        .MoveLast
        .move -move
    End If
    'move to new record
        .AddNew
    End With
 

Users who are viewing this thread

Back
Top Bottom