Delete record row on click

DuMont

Registered User.
Local time
Today, 07:57
Joined
Jul 31, 2014
Messages
24
Hi Guys,

I have a form in which is used as two separate things - one being a patient lookup & the other being a credit card form.Once they search for a patient all that patients info populates & if they chose to make a payment they fill out the second side of the form ...

My question is - When the employee uses the form just as a lookup it still saves the record to the table, it's just incomplete. Meaning the table is only used for a complete form. So I created a button that would make everything "" & then also added a docmd.runcommand accmddelete record

But this doesn't work as if they user continues to click on it will delete ALL the records in the table - I just want it to delete the incomplete record they currently are on & nothing else. I messed around with me.undo but once again, if you continue to click it will just cycle through all records you inputed to the table.

Any ideas how to just delete the current entry?
 
Would creating a simple query of the table with a filter to only show records ares null or blank , this way all you would have to do is click on the record and delete , The query could be opened with a command button on your Switchboard or form .
Just a thought
Regards Ypma
 
Last edited:
I use also a button to delete the actual record in a form
setfocus was important to get the focus from a subform always on the main form

Dim rst As Object
Set rst = Me.RecordsetClone
On Error Resume Next
rst.MoveLast
On Error GoTo 0
If rst.RecordCount > 0 Then

Forms!"yourform"!"yourfield".SetFocus
If MsgBox("Deleting record. Are you sure?", vbYesNo) = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Me.Refresh
End If
End If
 
Further to my last the following seems to work for me , providing your table has no relationships. try the script below in a command button


#Private Sub Command163_Click()
On Error GoTo Command163_Click_Err
On Error Resume Next
DoCmd.GoToControl Screen.PreviousControl.Name
Err.Clear
If (Not Form.NewRecord) Then
DoCmd.RunCommand acCmdDeleteRecord
End If
If (Form.NewRecord And Not Form.Dirty) Then
Beep
End If
If (Form.NewRecord And Form.Dirty) Then
DoCmd.RunCommand acCmdUndo
End If
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If

Command163_Click_Exit:
Exit Sub
Command163_Click_Err:
MsgBox Error$
Resume Command163_Click_Exit
End Sub#
 
...
My question is - When the employee uses the form just as a lookup it still saves the record to the table, it's just incomplete. Meaning the table is only used for a complete form. So I created a button that would make everything "" ...
What you've here is oddly, create a search form instead. If a person is found and the user want to add/edit some information then open the "input" form by a button or key combination from the search form.
 

Users who are viewing this thread

Back
Top Bottom