A
Andrew
Hi All,
I need a little help on the coding below. Thank you in advance!
Private Sub cboRecipientID_Dirty(Cancel As Integer)
Dim Response As String
Response = MsgBox("If you change the Recipient than the associated
subsidies will be deleted." & _
"Are you sure you want to change the Recipient?", vbYesNo)
If Not IsNull(cboRecipientID) Then
If Response = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunSQL = ("DELETE * FROM tblSubsidy WHERE
tblSubsidy.RecipientID" = "[Forms]![frmSubsidySubFrmPlacement]![RecipientID]")
DoCmd.SetWarnings False
Else
If Response = vbNo Then
Cancel = True
End If
End If
End If
End Sub
A little back ground info -
I have a form,frmplacement, that has its record source from a table called
tblplacement. This table has a combined key and one of the keys is
recipientID another is placementID. The placementID is an autonumber created
when a new record is made in the form frmplacement and table tblplacement. On
this form, frmplacement, the RecipientID is selected from a combobox drop
down.
On frmplacement I also have subform, frmSubsidySubFrmPlacement, who's record
source is a table called "tblsubsidy". This table also has a combined key, of
which one of the keys is recipientID the other is placementID.
The issue:
If a user changes the combobox entry,recipientID , on the placement form and
saves the record a new record is created in the tblsubsidy table. This is due
to the combined key and is expected but not what I want. As such, the
previous record also still exists because of the combined key. However I wish
to have it deleted when the recipientID is changed. The subsidy record must
be associated with the combined placementID and the recipientID.
The VB:
I wish to advise the user when they change the combobox, recipientID, that
the subsidy record associated with that recipientID, will be deleted and when
they click yes the record is deleted.
Hope that makes sense.
Cheers,
Andrew
P.S. For some reason i am getting an error with DoCmd.RunSQL, access is
telling me 'Arguement not optional'.
I need a little help on the coding below. Thank you in advance!
Private Sub cboRecipientID_Dirty(Cancel As Integer)
Dim Response As String
Response = MsgBox("If you change the Recipient than the associated
subsidies will be deleted." & _
"Are you sure you want to change the Recipient?", vbYesNo)
If Not IsNull(cboRecipientID) Then
If Response = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunSQL = ("DELETE * FROM tblSubsidy WHERE
tblSubsidy.RecipientID" = "[Forms]![frmSubsidySubFrmPlacement]![RecipientID]")
DoCmd.SetWarnings False
Else
If Response = vbNo Then
Cancel = True
End If
End If
End If
End Sub
A little back ground info -
I have a form,frmplacement, that has its record source from a table called
tblplacement. This table has a combined key and one of the keys is
recipientID another is placementID. The placementID is an autonumber created
when a new record is made in the form frmplacement and table tblplacement. On
this form, frmplacement, the RecipientID is selected from a combobox drop
down.
On frmplacement I also have subform, frmSubsidySubFrmPlacement, who's record
source is a table called "tblsubsidy". This table also has a combined key, of
which one of the keys is recipientID the other is placementID.
The issue:
If a user changes the combobox entry,recipientID , on the placement form and
saves the record a new record is created in the tblsubsidy table. This is due
to the combined key and is expected but not what I want. As such, the
previous record also still exists because of the combined key. However I wish
to have it deleted when the recipientID is changed. The subsidy record must
be associated with the combined placementID and the recipientID.
The VB:
I wish to advise the user when they change the combobox, recipientID, that
the subsidy record associated with that recipientID, will be deleted and when
they click yes the record is deleted.
Hope that makes sense.
Cheers,
Andrew
P.S. For some reason i am getting an error with DoCmd.RunSQL, access is
telling me 'Arguement not optional'.