delete a record on close

  • Thread starter Thread starter Gregory Hickmott
  • Start date Start date
Gregory Hickmott said:
i need to delete incomplete records when the form is closed

You need to give us much more information.

1. Which records?
2. What consitutes an incomplete record?
2. How many records?
3. How/when is the form closed?

If you just need to delete any record which isn't finished because a certain
field isn't filled in, you could so something like this in the form's
BeforeUpdate event(Air code):

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Len(Me.txtWhatever & vbNullString) = 0 Then
MsgBox "Discarding incomplete record", vbOKOnly, "Deleteing ..."
Me.Undo
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
its an add record for case
the case has to have one sample and a set of resualts for it to be completed

A case is started by selecting a client betwen this time and the time the
user select a procedure i need to keep the user form closeing the form (or
delete the case that has no samples) once a porcedure is selected then there
is at least one sample is setup
deleteing current record on close does not work

Private Sub Form_Close()
if FQLStatus=2 then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
end if
DoCmd.OpenForm "desktop", acNormal
End Sub

disabling closebutton will not let me set it at run time

Private Sub Form_BeforeInsert(Cancel As Integer)
FQLStatus = 2
CloseButton = False
PageEdit.Visible = False
End Sub
 
deleteing current record on close does not work

No it does not. You cannot delete a record which has not yet been written to
the database, but you can UNDO it in the form's BeforeUpdate event, if it
does not meet your criteria, then either just cancel the action and move on
or close the form. Again:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Len(Me.txtWhatever & vbNullString) = 0 Then
MsgBox "Discarding incomplete record", vbOKOnly, "Deleteing ..."
Me.Undo
DoCmd.Close
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top