J
Jody
I have a form that lists all records in a particular
table. From this "list form", I can call another form via
command buttons containing the record's details and can
then edit, add new records, or delete the selected
record. When the delete button is selected, I open the
form containing the detail so that the user can see the
entire record, put up a msgbox to confirm, and upon
receiving a yes, I delete the record, close the form, and
return to the original list, and requery to refresh the
view. My code looks like this:
Private Sub cmdDelete_Click()
Dim stDocName, strMsg As String
Dim stLinkCriteria As String
stDocName = "frmProduction"
stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
strMsg = "Delete this record?"
If MsgBox(strMsg, vbYesNo, "Confirm") = vbYes Then
DoCmd.SetWarnings False
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, ,
acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, ,
acMenuVer70
DoCmd.SetWarnings True
DoCmd.Close
Else
DoCmd.Close
GoTo Exit_cmdDelete_Click
End If
End Sub
This is a coding style that I use for a number of forms
that list table contents. In all but one of these forms,
the underlying query selects from one table, and this
delete code works correctly. However, one "list form"'s
query joins two tables. For this form, the code deletes
the current record, but then adds a new record with
default values filled in. I don't understand why it
should function any differently. When I run debug and
look at the ID field, it is using the correct one.
Does anyone have any thoughts?
Thanks much,
Jody
table. From this "list form", I can call another form via
command buttons containing the record's details and can
then edit, add new records, or delete the selected
record. When the delete button is selected, I open the
form containing the detail so that the user can see the
entire record, put up a msgbox to confirm, and upon
receiving a yes, I delete the record, close the form, and
return to the original list, and requery to refresh the
view. My code looks like this:
Private Sub cmdDelete_Click()
Dim stDocName, strMsg As String
Dim stLinkCriteria As String
stDocName = "frmProduction"
stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
strMsg = "Delete this record?"
If MsgBox(strMsg, vbYesNo, "Confirm") = vbYes Then
DoCmd.SetWarnings False
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, ,
acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, ,
acMenuVer70
DoCmd.SetWarnings True
DoCmd.Close
Else
DoCmd.Close
GoTo Exit_cmdDelete_Click
End If
End Sub
This is a coding style that I use for a number of forms
that list table contents. In all but one of these forms,
the underlying query selects from one table, and this
delete code works correctly. However, one "list form"'s
query joins two tables. For this form, the code deletes
the current record, but then adds a new record with
default values filled in. I don't understand why it
should function any differently. When I run debug and
look at the ID field, it is using the correct one.
Does anyone have any thoughts?
Thanks much,
Jody