Enforce Relationship Rules As If Deleting Record

May 25, 2006

Hello again,

Does anyone know if this is possible and is there an easy way to set it up?

My db has many relationships, hence if you attempt to delete a record from the table, it will not allow it if there are related records.

This is great, however.

My intention is to disable any record deletions. Instead, once a record is no longer live, the status of that record is set to disposed,exipired, etc.

I want to force the same rules as if attempting to delete this record but set to the status field.

Example message.
ie, Warning! You cannot dispose of this PC. There a related records in the Software License and Contracts Tables. Please reassign them and try again!

Any clues would be great.

Thanks All.

View Replies


ADVERTISEMENT

Tables :: Enforce Business Rules Though Referential Integrity

Nov 7, 2014

I am building a new project which has some core tables..

The key tables are:

Countries
CountryID
CountryName

Businesses
BusinessID
BusinessName
CountryID

Clients
ClientID
ClientName
BusinessID
CountryID

I want to enforce the rule that a Business can only have clients within the same country.

Can I enforce this through referential integrity in Access ? Do I need to redesign my tables ?

View 3 Replies View Related

How To Enforce Relationship Integrity Of SQL Tables From MS-Access?

Feb 12, 2005

Hello everyone. I'm not sure should I post this question here or at SQL Forum? However, my problem is this. I have 2 Tables, Table1 has AutoNumber as primary key, my second Table2 has index key field. I have one-to-many relationship on those two fields, with enforce referential integrity, cascade update and delete


The access program works fine until I upsized to SQL server. [u]Then I was unable to perform cascade update or delete. I have check SQL table (which I have little knowledge about) and seems to be okay, the relationship exists. But at ms-access I was unable to make the cascade update and delete.



I appreciate any help …. Thanks.

View 3 Replies View Related

Relationship Window, Enforce Referential Integrity Greyed Out

Mar 29, 2007

Hello..

I have a simple database of 4 tables.

luTblJobTitle
JobTitleID (pk)
JobTitle

luTblReason
ReasonID(pk)
Reason

tblDateReason
DateReasonID(pk)
EntryNumber(fk)
Date
Reason
Entered

tblEmpMain
EntryNumber(pk)
EmployeeNumber
Etc//

I have a 1 to many setup between tblEmpMain and tblDateReason.

When I try to setup the relationship between the "reason" field in tblDateReason and luTblReason, Referential Integrity along with the other two check boxes are greyed out.

It still shows one to many but it will not let me enforce referential intergrity.

Why is this? Did I setup the database wrong? Or am I trying to do something I shouldn't be doing??

I have attached the db.. It is split with both the backend and the front end.

R~

View 2 Replies View Related

Set Relationship Between Two Tables - Violates Referential Integrity Rules

May 14, 2013

I am new to access and I am trying to set a relationship between two tables, with the data types the same but keeps coming up with violates referential integrity rules....and I simply do not understand what this means, and how to solve it...

View 6 Replies View Related

Enforce Minimum Record Count

Jun 1, 2007

Does anyone have a good technique for enforcing a minimum number of records in a table?

I am attempting to ensure that in a table of Roles, there be a minimum of two Roles defined as Technicians. The field which identifies a Role as Technician is a Boolean.

I wrote a Function which does a domain lookup to count the number of Roles defined as Technician and am calling it from the BeforeUpdate event.

However, if there are 2 Technician Roles, and I mark a third Role as Technician, change my mind and try to unmark it...of course the Function can still see just the 2 existing.

I realize I can Undo the edit, but a user may not.

Thanks for any help.

View 4 Replies View Related

Deleting Records And A One To One Relationship.

Mar 19, 2007

Hello all,

I have 3 tables:
1. customer
2. DVD collection
3. Borrow

The aim of this system is to create a home borrowing system.

The customer table has a one to many relationship with the borrow table, while the dvd collection has a one to one with borrow. I can create a new book with no problem, and even view these on a form. Here my proble arises.

I ahve another form to return a DVD. I view the records from the borrow table, and once found what i want there is a button which deletes the record from the borrow table. Sadly, when i press this button, not only does it delete the record in the borrow table, but it will also delete the record from the DVD collection table.

I have tried everything i can think of, and i don't want to change to change the design as i have found this mnethod very easy to generate reports and the like. Any help??

Thanks

EDIT: the button i used was from the wizard that comes up when you create a button.

View 2 Replies View Related

Deleting All Related Sub Records When Deleting The "main" Record.

Apr 12, 2008

I have two tables.

1. Persons (list of persons)
2. Job history (list of jobs)

each person have their own job history. all these jobs are stored in the job history table. when i delete a person i would like the job history for this person deleted as well. each job stored in the job table have a field with person name, so that it is linked to this person.

how can i do this? vba or simple properties options?

- Roy

View 1 Replies View Related

Modules & VBA :: Event Information - Deleting Record Creates A Blank Record

Sep 8, 2013

I have a form set to the table Client Information with a subform set to the table Event Information. Client Information has a one to many relationship to Event Information.

There is a button that deletes the current record in Client Information--also deleting the related records in Event Information--then closes the form. The code works fine but a blank record in Event Information is apparently being created before the form closes.

Here's the VBA that I'm using:

Private Sub CmdDelReturn_Click()
Dim CmdDelReturnMsg As String
CmdDelReturnMsg = MsgBox("Delete event & client then return to front?", vbYesNo + vbDefaultButton1, "Delete and Return?")

[Code] ....

It's not a big deal because the button won't be used often and I can manually go into the table to delete the blank record. But if there's a simple solution to prevent this that would be nice.

View 3 Replies View Related

Deleting Record Using Main/Subform While Maintaining Record Position

Jul 6, 2006

Hello All,

I have an ordering db that utilyzes the typical Form / Subform layout. I
would like to be able to delete a record from the Main form and maintain the
same postion relative to the other records. For example, if I am scrolling
through the records and want to delete record #45, After I delete it I would
like to be able to have record #44 visible to the user.

I am currently using (2) SQL statements to delete the records from the main
Order table and the Order Details table which are linked without Cascade
Delete Related Records being on.

I had set-up a recordset procedure to try and find the bookmark set before
deletion but the only way I can get the sub-form to not show a blank form (no
controls visible for the record just deleted and the #deleted in controls on
the main form) is to requery after the delete, which loses the bookmark. If
i place the ReQuery at the end it displays the records properly, (without the
blank record) but returns the record to the first record. I have tried
turning off any sorting references to OrderBy, etc. but it still returns to
the first record.

I have also tried using "DoCmd.RunCommand acCmdDeleteRecord" but it doesn't delete the record from both tables.



Dim rst As Recordset
Dim strSearchName As String

Me.AllowDeletions = True
Me.sfmOrderDetails.Form.AllowDeletions = True

Set rst = Me.RecordsetClone
strSearchName = Str(Me.sfmOrderDetails.Form.txt_Order_No.Value)
rst.FindFirst "Order_No = " & strSearchName

CurrentDb.Execute "DELETE Order_ID FROM tblOrderDetails WHERE Order_ID = " &
Order_ID,dbFailOnError
CurrentDb.Execute "DELETE Order_ID FROM tblOrders WHERE Order_ID = " &
Order_ID, dbFailOnError

Me.Requery
Me.sfmOrderDetails.Form.Requery

Me.Bookmark = rst.Bookmark
Set rst = Nothing

Thanks!

View 6 Replies View Related

Deleting A Record With VB

Jun 15, 2005

Hi

I have a form with a "Clear Form" button on to allow the user to delete the record they are working on without updating the database. A question window pops up asking if they are sure they want to delete the record, if they answer yes the form will clear and re-load without updating the database.

The OnClick Event Procedure will not allow me to delete the data, it always saves. I've tried
DoCmd.SetWarnings False
If MsgBox("Are you sure you want to abandon changes to this record?", vbExclamation + vbYesNo, "LogBook 2002") = vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Else
DoCmd.SetWarnings True
End If
but I get the error "2046 - The command or action DeleteRecord isn't available now." Is there another way, a better way?

View 9 Replies View Related

Deleting A Record

Nov 22, 2006

Hi All,

I have a very simple name and address DB. What I would like to know is "What is the easiest way of finding a record using the switchboard and then deleting that record from the DB?"
I am an Access novice so nice easy replies would be appreciated.

Many Thanks
Keith:o

View 4 Replies View Related

Deleting Record After Use

May 6, 2007

Hi All

I have 2 tables "Customers" and "Work in Progress (WIP)"

The "WIP" table is result of the form "WIP" where I input all my data for each job completed. I use a lookup control "JobNo" to input the customer details from the table "Customers".

The objective is to call up the customer details into "WIP" add the job details, then on save, delete the record in the "Customers" table.

If this is possible, could you give me some ideas how.

Thanks in Advance.

Geoffk

View 5 Replies View Related

Deleting A Record

Nov 9, 2005

If you delete a record, the auto number is deleted but the following number remains unchanged e.g. 1 2 4 5 6 (Record 3 deleted). How can you rebuild a table so the auto number remain sequential. Using Access 2003

Dave

View 4 Replies View Related

Deleting A Record

Oct 12, 2006

I have a form that is normally populated with records from a table based on a query. I have a new requirement that would allow the form to be a "New Record" that they could enter information and save to the table that is mentioned above. My problem is unless they finish entering data, I would like this record to NOT be saved to the table. If they enter no data, the record is currently not saved, which is good. If they enter any data but do not finish, the table is saved, which is not good.
Is there a delete last record, or is there a better way to do this. The table is replicated so the ID's are
random.
Thanks

View 3 Replies View Related

Deleting Or Undoing A Record

Feb 11, 2008

Hi,

how do you cancel,undo a record made from a form? my scenario is this.
i open a form, a value is passed to the form automatically and a new record is created. i can then enter my info on the subform as needed. sometimes i dont have the right info or need the right to cancel. i have tried the following:

If (me.Dirty = True) Then
Me.undo
End if
DoCmd.Close acForm, me.Name

along with

CancelEvent
doCmd.close

both do not undo the record created in the main form which is what i need to do. i also thought of taking the record number via code and finding and delting it but that doesn't work either.

is there way to do this? im sure there is.

many thanks,

Nigel

View 1 Replies View Related

Deleting The Last Record Where Key Is Autonumber

Nov 3, 2004

I have a situation where I need to delete the last record I entered.

This is the sequence

1. The user selects that they want to add a new record (customer order)
2. I (using a macro) append a new record with some information filled out. This is shown in an input form (with lots of other info displayed) and I save the autonumber key to an invisible text field.
3. The user can then either SAVE or CANCEL. In the cancel I need to delete the record that was just added (see step 1.)

The problem is I need to close the form before I delete the record (thus removing the invisible text field containing the key to the newly created record). Once I close the form I don't know how to determine which record to delete (since I no longer know the Key) and I can't delete the record while the form is open since it is locked.

I am probably not doing this incorrectly but my issue is:

How do I delete (using SQL) the latest record an individual has created (which will always be the highest autonumber Key with the userID equal to this users's ID)?

Any ideas????

Thanks

View 1 Replies View Related

Modules & VBA :: Deleting Only One Record?

Apr 3, 2014

How do I delete only one record in a table that has duplicate records using SQL?

Code:
DELETE tblTemp.Fruit, tblTemp.[Country of Origin], tblTemp.Qty, tblTemp.Date, tblTemp.Currency
FROM tblTemp
WHERE (((tblTemp.Fruit)='Fruit') AND ((tblTemp.[Country of Origin])='Country of Origin') AND ((tblTemp.Qty)='Qty') AND ((tblTemp.Date)='Date') AND ((tblTemp.Currency)='Currency'));

View 10 Replies View Related

Error Deleting Record In Table

Mar 16, 2005

I have a corrupt record in a table that I am trying to delete. I keep getting the following error when I try and delete the record: "The search key was not found in any record".

Can anyone help me with this. All I am trying to do is delete this one record

Thanks!

View 1 Replies View Related

Refresh Subform After Deleting Record

Jan 10, 2006

Ok heres the situation, I have one form(frmBikes) that i use to filter the results in a subform(frmSubBikes). From the main form i have a button which opens another form(frmSell) which allows me to enter the sold price and when "cmdSell" is pressed many delete and append queries are run on the data stored in (frmSubBikes). When this button is pressd the deleted record has #deleted in each field where as it should be gone and i get this error message.
(The expression you entered refers to an object that is closed or does not exist)
What do i need to change? my minds been off this project for ages now ive got a brain block so help would be appreciated.

this is the code for "cmdSell"

If MsgBox("You are about to complte selling transaction: " & r & ". " & Chr(13) & " Is that correct ? ", vbQuestion + vbYesNo, " User Accounts") = vbYes Then

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70


DoCmd.SetWarnings False
DoCmd.OpenQuery "appSoldBikes", acNormal, acEdit
DoCmd.OpenQuery "UpdSoldBikes", acNormal, acEdit
DoCmd.OpenQuery "DelHires", acNormal, acEdit
DoCmd.OpenQuery "DelRepairs", acNormal, acEdit
DoCmd.OpenQuery "DelSoldBikes", acNormal, acEdit
DoCmd.Close
Me![frmSubBikes].Form.Filter = Searchstr
Me![frmSubBikes].Form.FilterOn = True
End If
Exit_cmdSave_Click:
Exit Sub

Hope you can help,
Thanks Sci

View 4 Replies View Related

Deleting A Record Through A Button In A Form?

Mar 15, 2006

Help needed! (Apologies if this is a stupid question !)

I'm making a database for my OCR A2 coursework.

I have a table set up for tenants, and have created a form through which the user can delete a record from that table.

I have a look up combo box, to select the record (tenant) for deletion, and a command button - using the wizard that came up I have selected "delete record" - but it doesnt work! It doesn't delete the record i have selected.

Why Is this not happening ? It also doesn't bring up a warning box saying "you are about to delete one record" or something similar?

Thanks xzxx

View 9 Replies View Related

#Deleted Showing Up After Deleting Record

Sep 5, 2006

Hello,

I've searched and searched but I cannot find a solution to my problem.

I have a combobox with a list of manufacturers. When you select one, the URL of their website shows up in a text box below.

I have a 'remove' button on the form and when you click it, it removes the manufacturer from the database. This works fine, but '#deleted' gets displayed in the text box. I've tried Me.Refresh, Me.Recalc, and requerying both the form and the field (I'm using Me.requery on the combo box, and it works fine there). I've also tried assigning the text box a blank value, but this doesn't work either.

I have the control source of the text box set to the URL field of the table that serves as the source of the form.

Here is my code:

Dim ManufacturerList As Control
Set ManufacturerList = Forms!frm_EditManufacturerList!cbo_Manufacturers

Dim URLBox As Control
Set URLBox = Forms!frm_EditManufacturerList!URL

Dim networkequipmentdb As DAO.Database
Dim RemoveManufacturer As DAO.Recordset

Set networkequipmentdb = CurrentDb
Set RemoveManufacturer = networkequipmentdb.OpenRecordset("ManufacturerSites")

RemoveManufacturer.Edit
RemoveManufacturer("Manufacturer").Value = ManufacturerList
RemoveManufacturer("DownloadPage").Value = URLBox
RemoveManufacturer.Delete

Me.cbo_Manufacturers = Me.cbo_Manufacturers.ItemData(0)
Me.cbo_Manufacturers.Requery
Me.URL.Requery
Me.Recalc

Me.cbo_Manufacturers.Value = ""
Me.URL = ""

Any help would be appreciated.

Thanks

View 1 Replies View Related

Deleting Child Table Record?

Jul 7, 2015

I have two tables in my access database with Parent Child relationship.Then i have below query based on which i have a datasheet form.

SELECT MOC_EMERGENCY.[MOC NUMBER], MOC_EMERGENCY.PERMANENT_MOC, MOC_DATA.TITLE
FROM MOC_DATA INNER JOIN MOC_EMERGENCY
ON MOC_DATA.[MOC NUMBER] = MOC_EMERGENCY.[MOC NUMBER]

When i delete a record in this form, my parent table record (in MOC_DATA table) is automatically deleted.

View 2 Replies View Related

Cannot Enforce Referential Integrity

Feb 3, 2006

Dear All,

Please see attached word document with a screenshot of my tables and their relationships. I'm trying to link from Table:Line,Field:Line to Table:Shift-Line and similarly with the shift table and access is not able to maintain referential integrity.

Can anyone explain why? and generally what I've done wrong with my relationships please?

Much Appreciated

Keji

View 8 Replies View Related

Modules & VBA :: Deleting Record From Table Or Query

Feb 20, 2014

I am trying to delete a record from a table and when I pass the variable as a text value it works but when I pass as a number I am getting a mismatch error.

I have to use it as a number as I am doing other update code in my database and it is a number.

Code:
DoCmd.RunSQL "DELETE * FROM TblIssueData Where tblIssueData.SerNum = ' & Me.txtserNum & ';"

When I am using TblIssueData SerNum as a text variable in table it works but when I specify SerNum as a number in the table it gives me data mismatch error. I have to leave it as a number for other VBA code in my database. I believe it is just a syntax error but not sure where to go with it.

View 2 Replies View Related

Reports :: Error When Deleting A Record From Form

Apr 18, 2013

I'm using MS Access 2003.

I have a form that displays in datasheet view. When I select a record and hit my keyboard's Delete button, I see the following error:

The Microsoft Jet database engine stopped the process because you and another user are attempting to change the same data at the same time.

This error *always* appears when deleting any record from this form. After clicking OK on this error, if I refresh the form, the record in question has indeed been deleted.

We use an Oracle back-end, and I have tried dropping the associated triggers, but the error message persists.

View 1 Replies View Related







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