Can't Save

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When a certain value is picked (CO4) form a combo box I have a form pop up
(BeforeUpdate). Then when I close the forms I get a pop up "You Cannot Save
This Record At This Time".

What am I missing????


Private Sub TR_PROBLEMCODESUFFIX_BeforeUpdate(Cancel As Integer)

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "f_Drugs"
If Me.TR_PROBLEMCODESUFFIX = "CO4" Then
Cancel = True

stLinkCriteria = "[ICNNO]=" & "'" & Me![ICNNO] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Sub
 
Dan, you cancelled the BeforeUpdate event procedure of the combo. Therefore
the value in the combo is not acceptable, and by extension, the record is
not acceptable. You try to close the form while the record is unacceptable,
so naturally enough, you can't save the record.

You could undo the record if you want to, e.g.:
Me.Undo

(You may need to use the AfterUpdate event of the control rather than
BeforeUpdate so you can undo the form.)
 
I feel so stupid - Yes After Update worked..
Thanks

Allen Browne said:
Dan, you cancelled the BeforeUpdate event procedure of the combo. Therefore
the value in the combo is not acceptable, and by extension, the record is
not acceptable. You try to close the form while the record is unacceptable,
so naturally enough, you can't save the record.

You could undo the record if you want to, e.g.:
Me.Undo

(You may need to use the AfterUpdate event of the control rather than
BeforeUpdate so you can undo the form.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Dan @BCBS said:
When a certain value is picked (CO4) form a combo box I have a form pop up
(BeforeUpdate). Then when I close the forms I get a pop up "You Cannot
Save
This Record At This Time".

What am I missing????


Private Sub TR_PROBLEMCODESUFFIX_BeforeUpdate(Cancel As Integer)

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "f_Drugs"
If Me.TR_PROBLEMCODESUFFIX = "CO4" Then
Cancel = True

stLinkCriteria = "[ICNNO]=" & "'" & Me![ICNNO] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Sub
 
Back
Top