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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Write Conflict 6
button VS drop down 2
Updating Data 5
ADD Mode 4
Add record and update List 5
Type Mismatch 3
Open based on two values 4
If Statements 2

Back
Top