Custom Record Deletion Sequence

Aug 7, 2007

I want to create a custom sequence when deleting a record but I'm having a problem.

What I want to do is prompt the user for the reason he/she is deleting the record and then archive this so it can be viewed in a log at a later time. This extra step is not as easy as I thought it would be.

What I did was put some coding into the On Delete event of the form. The code opens a form with a text box. The user can enter the reason for the delete in the text box and click OK or click cancel to abort the deletion.

My problem here is opening another form from the On Delete event. As soon as the form is open, the code just passes to the next step of the sequence and deletes the record.

There are 2 approaches that I've thought of but I'm not happy with either.

Approach 1:
In the On Delete event, set Cancel to True. That way the deletion is not handled by the delete sequence but rather by the new form that opens. The problem is that deleting a record from another form is not that simple. What I've tried is to execute a SQL statement that grabs the ID of the record from the open form and delete it. The problem is that although the record is deleted, all the fields on the form say #Deleted in them which is not that pretty. (Maybe there's some other way to do the deletion without this problem that I'm not aware of...?)

Approach 2:
Use an Inputbox. Unlike a custom form, the Inputbox delays execution of the code so the code can determine from the results (i.e. should it cancel the delete if the user clicked Cancel). The problem with Inputboxes is that they are not very flexible in the layout, they look pretty "packaged" (i.e. they look to me like the programmer didn't bother creating a means to enter a value). There's no way to place the buttons where you want or have it do better validation (e.g. I want the FORM to check that there's at least a few words describing why the user is deleting the invoice rather than have the form with the record get the input message passed back and then give an error and then pop open the Inputbox again)

I think that especially when you're creating an application with anything financial, you'll want to log a deleted invoice including the date, amount, possibly the client's name, invoice number, reason for deletion and the login name of the person doing the deletion. All of these are easy to record other than the reason.

Help would be much appreciated.

SHADOW

View Replies


ADVERTISEMENT

Record Deletion In My Forms

Apr 14, 2006

I have a form with a sub-form and a sub-sub-form :p
If I try to delete the record being viewed in the sub-form using
With DoCmd
.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End With

Then I here a ding (like you do when you try to delete a record) but I see no record delete confirmation box come up, if I hit enter, it deletes. So its there, but I can't see it, it's not behind the form either.
Any ideas?
Cheers

View 2 Replies View Related

Record In Subform Won't Allow Deletion

Jul 20, 2005

hiya

i have a subform which won't allow me to delete a record unless i'm in the datasheet view. is there anyway to change this. the properties have been set to allow deletions.

thanks
trish

View 7 Replies View Related

Incrementing Counter And Record Deletion

Apr 1, 2007

Hi,

The user wants all of the records in the database to have continuous numbering. I have used AutoNumber in the past but if you delete a record, it produces gaps in the numbering.

I was wondering if there is a way to number the records so they are always numbered continuously (1,2,3,etc.) even if some record is deleted.

I have tried using the following:


Set db = CurrentDb()
Set recordlist = db.Openrecordset("SELECT Max(tblContactHistory.ItemID) AS MaxID FROM tblContactHistory")

ItemID = (recordlist!MaxID + 1)

recordlist.Close
Set recordlist = Nothing


but I still cannot get the records to have continuous numbering after a record is deleted.


Any helped would be appreciated.

Thanks!

View 1 Replies View Related

Problem Inserting A Record After A Deletion

Apr 25, 2006

I have a form and a subform. There are a number of buttons on the form, allowing me to add, update, delete, etc. records from the subform. The process is that I select a record on the subform, its details are displayed on the form, then clicking on <Delete>, for example, removes it.

Each of these processes work fine on their own and also if carried out one after the other, for the most part. The one problem I'm finding is when I delete a record.

Firstly, the subform appears to refresh and the record is no longer shown. However, if I then try to select another row from the subform, I get a message saying 'record is deleted'. I click on <OK> to remove this message and I can then select the same row or another row without any problems.

Secondly, if I now try to add a new record (the code behind the button is just 'DoCmd.GoToRecord , , acNewRec'), I get a message saying that I can't go to the selected record.

If I close and reopen the form between each activity, all works fine, suggesting that something isn't refreshing properly. I've tried putting 'Me.refresh' and 'Me.requery' immediately after running the deletion, but to no effect.

Any suggestions?

View 5 Replies View Related

Modules & VBA :: Add Record Name To Deletion MsgBox

Aug 19, 2013

I'm using this stardard piece of code on a button that deletes a record from a simple continuous contact form.

Code:
If MsgBox("Do You Want To Delete This Record?", vbQuestion + vbYesNo + vbDefaultButton2, "Delete?") = vbYes Then
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
End If

If the form is called "CONTACTS" with a field called "Contact_Name", what code do I use to have the relevant Contact_Name appear in the MsgBox to be sure that I'm deleting the correct record ...... something like this .....

Do You Want To Delete The Record Called Paul Quinn ?

View 2 Replies View Related

Table With Key In Two Fields - Record Deletion

Oct 21, 2015

I have a table whose key is two fields. I am having no luck in selecting a given record from a form and deleting it. No problem in a table with a single field key.

View 14 Replies View Related

Modules & VBA :: Reset Autonumber After Record Deletion

Jul 16, 2015

We need to reset the autonumber after the last record is deleted.

For example:
2006
2007
2008

if 2008 gets deleted, we want the autonumber to reset back to 2008 rather than move to 2009.

Is this possible? This is the code we are using but cannot get the string to recognize the variable. If the variable is replaced with a number, it works, but it defeats the purpose of adding the plus 1 to the last autonumber.

Code:
Private Sub Command0_Click()
Dim RLMax As Integer
Dim Statement As String
RLMax = DMax("[id]", "Table1")
RLMax = RLMax + 1

strSQL = "Alter table table1 Alter Column Id Autoincrement(RLMax,1)"
DoCmd.RunSQL strSQL
End Sub

I realize we don't want to depend on the autonumber for anything other than a row identifier, but the table is setup that it is important for the rows to be sequential if the last record is deleted. Only if the last record is deleted.

View 12 Replies View Related

General :: Unwanted Deletion Related To Particular Record In Conversation Table

Mar 6, 2013

I have 2 tables.
1- customers table with 2 fields : customername,customerno
2-conversationstable with 4 fields: date,customername,customerno,details

The conversations table is for keeping memo of telephone conversations with the customers.

I built a simple form deriving from the conversations table. And added to it a combobox with 2 columns from customers table to select the customername an customerno for the form.

While deleting the record in the conversations table,through the form, I saw that the customername and customerno in the customers table of that particular customer record are deleted also. I made no links between both tables.

I wonder why that happened.

View 1 Replies View Related

Matrix View Allowing Checkbox For New Record Creation / Deletion?

May 29, 2013

What I would like to do it take all 'RoleTitle' from RolesList, all 'CourseID' from courselist and show them as a pivot table/matrix with a checkbox that creates or deletes entries from the RoleRequirements table. So, if it exists in the RoleRequirements table then it should appear a checked, unchecking it would delete it from the table.

I am using access 2010 with a SQL server 2005 backend.

View 3 Replies View Related

Record Sequence....

Apr 4, 2007

Hi... i have a excel file..... from which i have imported records.... after importing.... the records sequence in my table has changed..... can anyone tell me how to preserve the sequence that i had in excel..........

View 3 Replies View Related

Generate Record Number Sequence In Query?

Mar 23, 2006

Hi -

Suppose I have a generic query that returns a group of records.

Is there some way to generate a field containing the number sequence of each record? E.g. if there are 10 records, generate the numbers 1 through 10?

Must be a simple way to do this, I'm just a bit dense today...

Thanks,

-g

View 1 Replies View Related

Create A Sequence Number For Each Record Associated To Foreign Key

Jun 6, 2012

I have data in a table that looks like the first table and I would like to write a query to update the sequence so it looks like the second table.

PersonID
Color
Sequence

1
Red

1
Blue

1
Green

2
Blue

3
Red

3
Blue

PersonID
Color
Sequence

1
Red
1

1
Blue
2

1
Green
3

2
Blue
1

3
Red
1

3
Blue
2

View 2 Replies View Related

Finding Sequence Of Fields Making A Unique Record

Aug 23, 2006

I have a MS Access 2000 database with 136 data tables in it. What I would like to do is execute a piece of VBA code which will list for me in another table, (for example: Field1: TABLE NAME Field2: FIELD NAME 1 Field2: FIELD NAME2 etc), starting left to right, how many fields would have to be combined in each table to represent a unique record.

For instance:

TYPE ID TEXT
1 1 "Cats"
1 2 "Dogs"
2 1 "Rabbits"

In this example a combination of the fields TYPE and ID give a unique record.

Any help most appreciated.

Dalien51

View 1 Replies View Related

Modules & VBA :: Reset Autonumber And Keep Sequence After Deleting Record

Feb 28, 2014

I have a Microsoft Access database with SQL Server backend with 10000 records in my table, I have a autonumber field and in my database the purpose of the autonumber field is just to keep the record sequence (not to treat as a unique identifier) and I don't want to use a number field to manually enter the sequence. Whenever the record is deleted or the user won't save the record, it put gaps in the record sequence, Is there any way to refresh the autonumbers automatically "After delete confirm" event or "After Insert/update" even.

View 13 Replies View Related

Custom Error Message On Create New Record

Sep 28, 2004

I have created a command button through the wizard that is basically:
DoCmd.GoToRecord , , acNewRec

Well, it puts all this code in the event:

Private Sub NewVerification_Click()
On Error GoTo Err_NewVerification_Click
DoCmd.GoToRecord , , acNewRec
InboundQuestions!Page1.SetFocus
VerificationNo.SetFocus
Exit_NewVerification_Click:
Exit Sub
Err_NewVerification_Click:
MsgBox Err.Description
Resume Exit_NewVerification_Click

End Sub

Well, my PK field is one users enter in manually (please don't ask why). What I need is something that checks to see if the number in that field is a duplicate key, so I can tell users via msgbox "Duplicate Number, try again". Right now, it's not that descriptive, it says "You can't go to the specified record". I guess all i need is an If statment, but I don't know the code that checks to see if [field1]'s value has already been used in my table. Any ideas?

View 4 Replies View Related

Modules & VBA :: How To Build A Custom Record Delete

Sep 24, 2013

I'd like to override the default behaviour for deleting records in a form.Specifically, I want to build my own custom delete procedure so that when the user presses the Del button, my code fires to complete the deletion of the selected record(s). In order to do that, I'd set Allow Deletions = No for that form. I'd also want to code the KeyDown event for the Del key so that if record(s) are selected, my custom delete code fires, else the default behavior for the Del key happens.I'm primarily interested in how I might code the KeyDown event.

View 12 Replies View Related

Modules & VBA :: Custom Record Counter Of A Form?

Jan 27, 2015

I have a custom record counter on a form using the below code:

Private Sub Form_Current()
If Me.NewRecord Then
Me.lblRecordCounter.Caption = _
"Record " & Me.CurrentRecord & " of " & Me.Recordset.RecordCount + 1
Else
Me.lblRecordCounter.Caption = _
"Record " & Me.CurrentRecord & " of " & Me.Recordset.RecordCount
End If
End Sub

I think at some stage the form was saved with a filter on and this may be causing the issue. The problem I have is:

There are 1749 records. Everytime I open the form the custom record counter displays "Record 1 of 501". The built in record counter shows 1 of 1749. The moment I hit the next record arrow the custom record counter displays "2 of 1749" and if I go back again it displays "1 of 1749.".

I know it's a filter causing the problem because I have a macro that does a clear search. As soon as I hit the clear search the custom counter goes back to "1 of 501" again (even though the built in one stays at 1 of 1749).

I have Filter on Load set to No.

what I am doing wrong?

View 13 Replies View Related

Modules & VBA :: Delete A Record With Custom CMD Button

Jul 12, 2015

I am building a db for reservations for my limo company. I want to have a cmd button that verifies the user to make sure she wants to delete a run. This is what I have so far:

Private Sub cmdDeleteRun_Click()
Dim Response
Response = msgbox("Are you sure you want to delete this run?", vbYesNoCancel + vbCritical, "Really delete run?")
If Response = vbYes Then

End Sub

I don't know what I am missing for the cmd to actually delete it.

View 3 Replies View Related

Modules & VBA :: Custom Record Navigation Buttons

Jul 11, 2014

To briefly explain my database; it is a bespoke referral management system within a hospital. Each record on the database contains patient demographic information, as well as information on their referral (i.e. date of referral, date of assessment, date of commencing treatment, discharge date etc.) Therefore, the same patient will appear multiple times in the database, with each separate record corresponding to a unique referral pathway.

The database forms are split to show patient information at the top, with referral information shown in a subform. I am trying to add navigation buttons to the subform that will allow the user to scroll through the referrals corresponding to the patient currently displayed on the main form.

Each patient has a uniquely identifiable number associated with them, and so it seems straightforward enough in my mind to have a button that will search for the record in the database where the patient's number matches the patient number of the current record, and where the referral date is minimum (for "First Referral"), maximum but less than current (for "Previous Referral"), minimum but greater than current (for "Next Referral"), and maximum (for "Last Referral").

View 5 Replies View Related

General :: Custom Message For When Record Locking Is Set?

Oct 20, 2014

My database has been set with the 'All records' locking option set to prevent two or more people editing files at once. This is working fine but I wondered if there is a way to make a more personal message appear instead of the default Access one, just to maintain a uniform look.

View 3 Replies View Related

Custom Pop-up Message When One Attempts To Add A Duplicate Record?

Dec 27, 2012

I would like to create a custom pop-up Message when one attempts to add a duplicate record.

Currently, I have a default pop-up message when you try to add a duplicate record. I set the field as Indexed= yes(No Duplicates) which generates a default pop-up message but it is technical and wordy. I would like to be able to simplify the wording to just let the user know not to add a duplicate record.

View 13 Replies View Related

Tables :: Custom ID Format That Increment Every Time New Record Added

Jul 25, 2013

How to make a custom ID format that increment every time you add a new record the sample ID look like this "HCCR-SMA-CV-ST-000".

View 4 Replies View Related

Deletion Of Certain Info Within A Row???

Aug 4, 2005

Hello Gurus,

I need to perform a massive deletion within Access and I want to find out if there is a simple piece of SQL that can be written to complete this task.

Example:

I have a table called GAB - one of the columns is called email addresses

Currently all the email addresses look like this: m14.dpitts@****.com

I need them to look like this: dpitts@****.com, so all I need to do is remove the 'm14.'

Is there something within Access that will accomplish this?? Kinda like substr in Oracle?

Any help would be great!!! :)

View 3 Replies View Related

Deletion Button

Jan 17, 2005

Can I add a delete button at the bottom of my form to allow me to delete a record or do i have to go to that table and delete it from there. if so how do i proceed with this.

thanks

View 2 Replies View Related

Simultaneaus Deletion Using RunSQL

May 18, 2005

can some one help.

i have two tables table1,table2 each with one same field Country.

In my RunSQl query, i want to delete all records in table1 and table2 simultaneously from one button with a certain country.
The problem is how can i do this from may be one RunSQL statement
i tried to use two deletion runSQl commands, but only one is executed. Actually the one that comes second.
If i put doevents in the middle of these statements, only the first is executed.

Here is my code:

Private Sub RemoveCtry_Click()
docmd.setwarnings false
Docmd.RunSQL "DELETE * FROM table1 WHERE (Country='" & USA & "')"
Doevents
Docmd.RunSQL "DELETE * FROM table2 WHERE (Country='" & USA & "')"
docmd.setwarnings true
End Sub

if I use One Statement:

Docmd.RunSQL "DELETE table1.Country,table2.Country FROM table1,table2 WHERE ((table1.Country='" & USA & "' ) AND (table2.Country=' " & USA & " '))"
I get an error that i have to specify the table to delete from!!!!

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved