David R
I know a few things...
- Local time
- Today, 11:05
- Joined
- Oct 23, 2001
- Messages
- 2,633
One works, the other doesn't. I'm not sure why.
1. Using NoMatch= True, with Limit to List set to No
2. Using NotInList, with Limit to List set to Yes
Any ideas? I keep getting a 2105 error, Cannot go to specified record. Is it because I am somehow still in the recordset clone from the previous event? If so, how do I escape that? I would like to use the events as they're designed, rather than reinventing the wheel.
TIA,
David R
1. Using NoMatch= True, with Limit to List set to No
Code:
Private Sub ParticipantID_Lookup_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Dim PIL As String
If (IsNull(Me.ParticipantID_Lookup)) Or (Me.ParticipantID_Lookup = "") Then Exit Sub
'Include check for Len(ParticipantID) = 6
PIL = Left(Me.ParticipantID_Lookup, 6)
If (Len(PIL) < 6) Then
MsgBox ("Make sure the ParticipantID has 6 characters.")
Exit Sub
End If
Set rs = Me.Recordset.Clone
rs.FindFirst "[ParticipantID] = '" & PIL & "'"
If rs.Nomatch = True Then
If (Me.NewRecord = True) Then
If (Me.Dirty = True) Then Me.Undo
Else
DoCmd.GoToRecord , , acNewRec
End If
Me.ParticipantID = Left(PIL, 6)
Me.ParticipantID_Lookup = ""
Else
'Go to the matching record
Me.Bookmark = rs.Bookmark
End If
Me.ParticipantID_Lookup.Requery
Me.subformDevices.Requery
Set rs = Nothing
End Sub
2. Using NotInList, with Limit to List set to Yes
Code:
Private Sub ParticipantID_Lookup_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Dim PIL As String
If (IsNull(Me.ParticipantID_Lookup)) Or (Me.ParticipantID_Lookup = "") Then Exit Sub
'Include check for Len(ParticipantID) = 6
PIL = Left(Me.ParticipantID_Lookup, 6)
If (Len(PIL) < 6) Then
MsgBox ("Make sure the ParticipantID has 6 characters.")
Exit Sub
End If
Set rs = Me.Recordset.Clone
rs.FindFirst "[ParticipantID] = '" & PIL & "'"
'Go to the matching record
Me.Bookmark = rs.Bookmark
Me.ParticipantID_Lookup.Requery
Me.subformDevices.Requery
Set rs = Nothing
End Sub
Private Sub ParticipantID_Lookup_NotInList(NewData As String, Response As Integer)
If (Me.NewRecord = True) Then
If (Me.Dirty = True) Then Me.Undo
' DoCmd.GoToRecord , , acLast
End If
Response = acDataErrAdded
DoCmd.GoToRecord , , acNewRec
Me.ParticipantID = Left(NewData, 6)
Me.ParticipantID_Lookup = ""
Me.ParticipantID.SetFocus
End Sub
Any ideas? I keep getting a 2105 error, Cannot go to specified record. Is it because I am somehow still in the recordset clone from the previous event? If so, how do I escape that? I would like to use the events as they're designed, rather than reinventing the wheel.
TIA,
David R