GotoRecord Last

Novice1

Registered User.
Local time
Today, 06:29
Joined
Mar 9, 2004
Messages
385
After appending data in a table, I open a particular form. I want to display only the last record. I've added the code (DoCmd.GoToRecord , , acLast) to the On Load and On Open properties without success (opens first record).

What am I doing wrong?
 
No. I imported data, using an Append Query. I want the user to add additional data.
 
So you want the other records to be available on the form, but you want it to go to the last record when it loads?

Use this in the Load event of the form:
Code:
Me.Recordset.MoveLast
 
Actually, no, I want only the last record to be available (other records have personal info).
 
In that case GoToRecord or MoveLast won't suffice. Are the records sorted accordingly? And what is the field that uniquely identifies each record?
 
Records are sorted. The member will always be working on the last record. Each record is uniquely identified with an autonumber field (SGLI_ID).
 
Code:
With Me.Recordset
    .MoveLast
    .Filter = "SGLI_ID = " & !SGLI_ID
End With
 
I'm still having difficulties. I used the following code but I'm getting a blank record vs. the last record. Any suggestions?

Private Sub Command294_Click()

On Error GoTo Err_Command294_Click

DoCmd.Close

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmCustomerInput2"
DoCmd.OpenForm stDocName, acPreview, , "[SGLI_ID] =" & Forms!frmCustomerInput1A!SGLI_ID

With Me.Recordset
.MoveLast
.Filter = "SGLI_ID = " & !SGLI_ID
End With

Exit_Command294_Click:
Exit Sub

Err_Command294_Click:
MsgBox Err.Description
Resume Exit_Command294_Click

End Sub
 
"Me." refers to the current form, you need to refer to the form that's being opened.
 
I'm so sorry but I don't understand. I don't see a Me. reference. Not sure what to do
 
Here's a question for you. If you are on form A and you want to refer to form B, how do you do that?
 
I'm getting "cannot find field SGLI_ID in your expression. Both forms are open, SGLI_ID field (unique) is in both forms. I don't know what next to try.


Dim stDocName As String

DoCmd.OpenForm "frmCustomerInput1A", acPreview, , "[SGLI_ID] =" & Forms!frmCustomerInput1!SGLI_ID
With Me.Recordset
.MoveLast
.Filter = "SGLI_ID = " & !SGLI_ID
End With

Exit_Command294_Click:
Exit Sub

Err_Command294_Click:
MsgBox Err.Description
Resume Exit_Command294_Click
 
I tried the references without success. I know you're trying to teach me. I have tried different combinations. I'm reeealllly trying. Do I reference the form with the recordset? The table? Another failed attempt ...


On Error GoTo Err_Command294_Click

DoCmd.Close

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmCustomerInput1a"
DoCmd.OpenForm stDocName, , , stLinkCriteria

With tblSGLIData.Recordset
.MoveLast
.Filter = "SGLI_ID = " & !SGLI_ID
End With


Exit_Command294_Click:
Exit Sub

Err_Command294_Click:
MsgBox Err.Description
Resume Exit_Command294_Click
 

Users who are viewing this thread

Back
Top Bottom