Update or CancelUpdate without an ad new or Edit

wjburke2

Registered User.
Local time
Today, 16:07
Joined
Jul 28, 2008
Messages
194
I have looked through many posts about this topic but none seem to fix my problem. I have a form bound to my inventory table not a query. It has a list box used to select the record to update. Everything seemed to be working until I tried to add Last_updated field in the Form_Before_Update procedure. Now I am getting the error about "Update or CancelUpdate without an ad new or Edit". I need to update certain fields once the user decides to commit. Below find my code. This is very frustrating what am I doing wrong. As you can see I commented everything in the before_update out to get it to work.

Option Compare Database

Private Sub Form_Current()

If Me.Form.Dirty Then
Me.Form.Dirty = False
End If

End Sub

Private Sub Form_Load()

If IsNull(Me.cmbTypeSelect) Then
Me.cmbTypeSelect = Me.cmbTypeSelect.ItemData(0)
End If
Call lstComponents_AfterUpdate

End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)

' Me.txtLast_Update = Date
'
' Me.txtPcsAdj = 0
' Me.txtBoxAdj = 0
' Me.txtPcsAdjed = 0
' Me.txtBoxAdjed = 0
'
' If Form.Dirty Then
' Call Audit_Trail
' End If

End Sub

Private Sub cmbTypeSelect_AfterUpdate()

Me.lstComponents = Null
Me.lstComponents.Requery
Me.lstComponents = Me.lstComponents.ItemData(0)
Call lstComponents_AfterUpdate

End Sub

Private Sub lstComponents_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[CompName] = '" & Me![lstComponents] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub

Private Sub txtPcsAdj_AfterUpdate()

Me.txtPcsAdjed = Me.txtOnHand + Me.txtPcsAdj
Me.txtBoxAdj = Me.txtPcsAdj / Me.txtBox_Qty
Me.txtBoxAdjed = Me.txtBoxes + Me.txtBoxAdj

End Sub

Private Sub btnAdjust_Click()

Me.txtOnHand = Me.txtOnHand + Me.txtPcsAdj
Me.txtBoxes = Me.txtBoxes + Me.txtBoxAdj

Me.txtPcsAdj = 0
Me.txtBoxAdj = 0
Me.txtPcsAdjed = 0
Me.txtBoxAdjed = 0

End Sub

Private Sub btnAuditTrail_Click()

Me.txtAuditTrail.SetFocus
DoCmd.RunCommand acCmdZoomBox
Me.txtAuditTrail.Undo
Me.btnAuditTrail.SetFocus

Exit_btnAuditTrail_Click:
Exit Sub

Err_btnAuditTrail_Click:
MsgBox Err.Description
Resume Exit_btnAuditTrail_Click

End Sub



 
It looks like the listbox you mention in lstComponents.

Is this bound or unbound?
 
lstComponents is not bound. Whatever is causing this has someting to do with trying to update in Form_Before_update. When I uncomment the fist line " Me.txtLast_Update = Date" it throws the error right there. I am wondering if the form being bound is not causing the record to update as the changes are made on the screen then when I choose to move to the next record or exit it hits the before_update and says sorry to late I have moved on already. The weird thing is all my screen in this project call audit_trail and most make last minute changes to fields. The only thing that has changed is I am now using a2010 I had a2003 for most of this development.
 

Users who are viewing this thread

Back
Top Bottom