G
Guest
I have delete button on my form that is working well except that is seems to
be resorting the records. For example when I delete record#45 it should go
to record#44. It opens the correct record with model, part and NHL, but the
record is no longer record#44. Any ideas?
Dim strSQL As String
Dim strModel As String
Dim strPart As String
Dim strNHL As String
strModel = Me.Model
strPart = Me.Part
strNHL = Me.NHL
strSQL = _
"DELETE * FROM AllNewParts WHERE " & _
"[Model#] = '" & _
[Forms]![NewPartInputfrm]![Model] & _
"' And [Part#] = '" & _
[Forms]![NewPartInputfrm]![Part] & _
"' And [NHL] = '" & _
[Forms]![NewPartInputfrm]![NHL] & "'"
CurrentDb.Execute (strSQL), dbFailOnError
With Me.RecordsetClone
If .RecordCount = 1 Then
DoCmd.Close acForm, Me.Name
Else
' Locate record to come back to.
.Bookmark = Me.Bookmark
If Me.CurrentRecord = 1 Then
.MoveNext
Else
.MovePrevious
End If
' Save this record's key info.
strModel = ![Model#]
strPart = ![Part#]
strNHL = ![NHL]
' Requery the form.
Me.Requery
' Position this form to the record
' whose keys we saved.
Me.Recordset.FindFirst _
"[Model#] = '" & strModel & _
"' And [Part#] = '" & strPart & _
"' And [NHL] = '" & strNHL & "'"
End If
End With
be resorting the records. For example when I delete record#45 it should go
to record#44. It opens the correct record with model, part and NHL, but the
record is no longer record#44. Any ideas?
Dim strSQL As String
Dim strModel As String
Dim strPart As String
Dim strNHL As String
strModel = Me.Model
strPart = Me.Part
strNHL = Me.NHL
strSQL = _
"DELETE * FROM AllNewParts WHERE " & _
"[Model#] = '" & _
[Forms]![NewPartInputfrm]![Model] & _
"' And [Part#] = '" & _
[Forms]![NewPartInputfrm]![Part] & _
"' And [NHL] = '" & _
[Forms]![NewPartInputfrm]![NHL] & "'"
CurrentDb.Execute (strSQL), dbFailOnError
With Me.RecordsetClone
If .RecordCount = 1 Then
DoCmd.Close acForm, Me.Name
Else
' Locate record to come back to.
.Bookmark = Me.Bookmark
If Me.CurrentRecord = 1 Then
.MoveNext
Else
.MovePrevious
End If
' Save this record's key info.
strModel = ![Model#]
strPart = ![Part#]
strNHL = ![NHL]
' Requery the form.
Me.Requery
' Position this form to the record
' whose keys we saved.
Me.Recordset.FindFirst _
"[Model#] = '" & strModel & _
"' And [Part#] = '" & strPart & _
"' And [NHL] = '" & strNHL & "'"
End If
End With