Zydeceltico
Registered User.
- Local time
- Yesterday, 21:39
- Joined
- Dec 5, 2017
- Messages
- 843
Hi All -
How do I modify the following code to go to the most recent record? You can see I tried inserting acCmdRecordGoToLast after the FindFirst but it doesn't work.
I also tried adding an If to the Else at the end like this:
This goes to the most recent record but it opens a "Enter Parameter Value" dialog box looking for "InspectionEvent_FK " which I don't want it to do as it is already recorded and shows up in the record after I click Cancel or OK in the dialog box.
What am I missing?
Thanks a bunch!
Tim
How do I modify the following code to go to the most recent record? You can see I tried inserting acCmdRecordGoToLast after the FindFirst but it doesn't work.
Code:
Private Sub Form_Load()
Dim rs As DAO.Recordset
If Not Trim(Me.OpenArgs & " ") = "" Then
'See if record exists
Set rs = Me.Recordset
'MsgBox Me.OpenArgs
rs.FindFirst "InspectionEvent_FK = " & CLng(Me.OpenArgs)
RunCommand acCmdRecordsGoToLast
If rs.NoMatch Then 'it does not exist so you need to create it
DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
Me.InspectionEvent_FK = Me.OpenArgs
Me.NavigationButtons = False
End If
Else
Me.cboPartType.RowSource = "qryFinalProductComponents2"
End If
End Sub
I also tried adding an If to the Else at the end like this:
Code:
Private Sub Form_Load()
Dim rs As DAO.Recordset
If Not Trim(Me.OpenArgs & " ") = "" Then
'See if record exists
Set rs = Me.Recordset
'MsgBox Me.OpenArgs
rs.FindFirst "InspectionEvent_FK = " & CLng(Me.OpenArgs)
If rs.NoMatch Then 'it does not exist so you need to create it
DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
Me.InspectionEvent_FK = Me.OpenArgs
Me.NavigationButtons = False
End If
Else
If Not Me.NewRecord Then
RunCommand acCmdRecordsGoToLast
Me.cboPartType.RowSource = "qryFinalProductComponents2"
End If
End If
End Sub
This goes to the most recent record but it opens a "Enter Parameter Value" dialog box looking for "InspectionEvent_FK " which I don't want it to do as it is already recorded and shows up in the record after I click Cancel or OK in the dialog box.
What am I missing?
Thanks a bunch!
Tim