What is the simplest fix so that if the BidServices has been filled for a particular bid, where fields such as estimated_days and markdown have been saved to the table, the user cannot delete these records if he were to change the combobox selection?
I tried putting code:
Code:
If IsNull(Me.subfrmBidServices.Form.Controls(Estimated_Days)) Then
CurrentDb.Execute "DELETE FROM BidServices WHERE Bid_ID = " & Me.txtBoxBid_ID
CurrentDb.Execute "INSERT INTO [BidServices] ([Bid_ID], [Service_ID]) SELECT " & Me.txtBoxBid_ID & " AS BID_ID, [Service_ID] FROM [RequestServices] WHERE [Request_ID] = " & Me.cboReqID
Me.subfrmBidServices.Form.Requery
Else
MsgBox "Clear Estimated Days before selecting different Request ID"
End If
but it seems glitchy
The new issue I'm facing is that when the user is browsing the Bids in Form View, if he were to accidentally change the combobox, the subform performs the DELETE and INSERT INTO, essentially deleting what was put for the estimated days and markdown.
And this code doesn't seem to be effective in stopping this.
EDIT:
I believe I solved my issue by putting this code in the BeforeUpdate() event of the cbobox
Code:
Private Sub cboReqID_BeforeUpdate(Cancel As Integer)
If Not Me.NewRecord Then
MsgBox ("This can only be selected on New Bids")
Cancel = True
Me!cboReqID.Undo
Else
End If
End Sub