G
Guest
I have the following code in a button. I have to use a delete button because
my query that populates my form has five table with left joins and if I do a
'normal' delete record, records from all my joined tables are deleted and I
only want the record from the AllNewParts table deleted. My problem is that
if there is more than one record when the button is clicked, I need the
record to delete and the form to refresh and open to the previous record or
the next record if the record being deleted is the first record. Any ideas
how I can accomplish this?
Private Sub Command121_Click()
Dim strSQL As String
If Me.Part = "" And Me.NHL = "" Then
Me.Undo
Else
strSQL = "DELETE * FROM AllNewParts WHERE [Model#] = '" &
[Forms]![NewPartInputfrm]![Model] & "' And [Part#] = '" &
[Forms]![NewPartInputfrm]![Part] & "' And [NHL] = '" &
[Forms]![NewPartInputfrm]![NHL] & "'"
CurrentDb.Execute (strSQL), dbFailOnError
End If
With Me.RecordsetClone
If .RecordCount = 1 Then
DoCmd.Close acForm, Me.Name
Else
my query that populates my form has five table with left joins and if I do a
'normal' delete record, records from all my joined tables are deleted and I
only want the record from the AllNewParts table deleted. My problem is that
if there is more than one record when the button is clicked, I need the
record to delete and the form to refresh and open to the previous record or
the next record if the record being deleted is the first record. Any ideas
how I can accomplish this?
Private Sub Command121_Click()
Dim strSQL As String
If Me.Part = "" And Me.NHL = "" Then
Me.Undo
Else
strSQL = "DELETE * FROM AllNewParts WHERE [Model#] = '" &
[Forms]![NewPartInputfrm]![Model] & "' And [Part#] = '" &
[Forms]![NewPartInputfrm]![Part] & "' And [NHL] = '" &
[Forms]![NewPartInputfrm]![NHL] & "'"
CurrentDb.Execute (strSQL), dbFailOnError
End If
With Me.RecordsetClone
If .RecordCount = 1 Then
DoCmd.Close acForm, Me.Name
Else