Solved Have subforms last record focused

oxicottin

Learning by pecking away....
Local time
Today, 13:04
Joined
Jun 26, 2007
Messages
889
Hello, I have a form with a subform and on the subform I usually enter 15 records or so. How can I always have the last and new if there is no records scrolled to so they are always visible when I go to each record from my main form and if im entering a record or working on a record.
 
Hi. Look into DoCmd.GoToRecord. Hope that helps...
 
I tried the below and the subform kinda flickers but the first record is visable and I have to school to next to last
Code:
DoCmd.GoToRecord , , acGoTo, Form.Recordset.RecordCount - 2
'set focus on the last record
DoCmd.GoToRecord , , acLast
 
I tried the below and the subform kinda flickers but the first record is visable and I have to school to next to last
Code:
DoCmd.GoToRecord , , acGoTo, Form.Recordset.RecordCount - 2
'set focus on the last record
DoCmd.GoToRecord , , acLast
Can you post a sample copy of your db with some test data?
 
How can I always have the last and new if there is no records scrolled to so they are always visible when I go to each record from my main form and if im entering a record or working on a record.
agree with dbGuy. post a sample. however, are you asking if you can always SEE records on your sub, regardless of what you are tinkering with inside your main form? that's what it sounds like.
 
To much to personal info to get rid of ect. This isn't a needed to do its just a want to do.... Thanks anyway!
 
To much to personal info to get rid of ect. This isn't a needed to do its just a want to do.... Thanks anyway!
How about creating a demo db with a similar structure as the forms you're having issues with? Just a thought...
 
This has worked for me for a number of years:
Code:
Private Sub Form_Current()
  Me.SubformName.SetFocus
  DoCmd.GoToRecord , , acNewRec
  Me.SubformName.Form!FirstControlName.SetFocus
End Sub
Linq ;0)>
 
This is what I do
Code:
Private Sub Form_Open(Cancel As Integer)
    Me.RecordSource = "qryEmails"
    Me.sfrmEmails.SourceObject = "cfrmEmails"
    Set Me.sfrmEmails.Form.Recordset = Me.Recordset
    DoCmd.RunCommand acCmdRecordsGoToLast
    DoCmd.GoToRecord acDataForm, Me.Name, acPrevious, 5 ' Needed for a continuous form as only last record shows.
    DoCmd.RunCommand acCmdRecordsGoToLast
    DoCmd.Maximize
End Sub
 
It works sorta if I use the code below to bring it to the last record and not the previous 2 but im ok with it....

Code:
Private Sub Form_Current()
    
    Dim sfrm1 As Control, sfrm2 As Control
    
    If Me.NewRecord Then
'Do nothing if new record
    Else
        Set sfrm1 = Forms!frm_ShiftDay!frm_ShiftMachinesRanSubform
        Set sfrm2 = sfrm1.Form!frm_MachineOutputSubForm
        
        sfrm1.SetFocus
        sfrm2.SetFocus

        Set sfrm2 = Nothing
        Set sfrm1 = Nothing
'set focus on the last record
        DoCmd.GoToRecord , , acLast
    End If
 
You could change the subform's RecordSource query to sort descending on a date field or on the autonumber. That will show the newest record on top.
 

Users who are viewing this thread

Back
Top Bottom