Solved

Access2010 Form Delete Issue

Posted on 2013-11-02
4
430 Views
Last Modified: 2013-11-03
I have a continuous form that uses the following SQL statement for it's record source.

strSQL = "SELECT Customer.Customer, RehabJobs.Address, Rehabjobs.CompletedDate, RehabJobs.RehabJobID, RehabJobs.CustomerType, Customer.CustAbrv, RehabJobs.Zip," _
        & " RehabJobs.JobName, RehabJobs.Lockbox, RehabJobs.RequestDate, RehabJobs.DueDate, RehabJobs.PMID, RehabJobs.JobDesc, RehabJobs.Amount," _
        & " RehabJobs.JobStatus, RehabJobs.ApprovalDate, RehabJobs.ScheduledDate, RehabJobs.ETCDate, RehabJobs.NewETCDate, RehabJobs.Notes, RehabJobs.NewETCReason, RehabJobs.CustomerID" _
        & " FROM Customer RIGHT JOIN RehabJobs ON Customer.CustomerID = RehabJobs.CustomerID" _
        & " Where ((Rehabjobs.closed) <> -1) AND ((Rehabjobs.JobStatus)<>11)" _
        & " ORDER BY Customer.Customer, RehabJobs.JobName, RehabJobs.RehabJobID;"

And when i use the forms record selector to delete a record. The form deletes both the customer record from the customer table and the rehabjob record from the rehabjobs table.

I just want to delete the record from the rehabjobs table.

Why is this.
Normally i control all deletions with VBA, but i was trying to speed things up a little with the development of the DB and thought i would take advantage of the built in functions.

Thanks Guys..

Jason
0
Comment
Question by:jb702
  • 2
4 Comments
 
LVL 4

Expert Comment

by:rshq
Comment Utility
Hi
  Maybe you use a relation between Rehabjobs  and Customer tables.
  In this relation "Enforce Referential Integrity" and "Cascade Delete Related Records"    probably checked .
0
 

Author Comment

by:jb702
Comment Utility
at first i didn't have any relationship at all. after this happened i went in and created a one to many, but am not able to use the enforce referential integrity because i already have lots of data.....and the message comes up and states i must have equal amount fields.

If i use a sQL statement that doesn't right join the customer table (the only reason i'm doing this is to populate the customer field with the customer name instead of the customerID) but embed a dlookup for the customer name i wouldn't  have to include the customer table in the sql syntax. Would this slow down performance.
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
Comment Utility
"Would this slow down performance. "

Generally, yes.  Domain functions (DLOOKUP, DMAX, DMIN) are notoriously slow.

My default form template (the one that every form in my application starts out looking like) has Allow Deletes = No.  If I want to allow my users to delete a record, I create a Delete button and put that, along with other buttons in the forms footer.  In that command buttons Click event, I either build the DELETE SQL statement on the fly, or execute a stored delete by passing the PK value associated with the record I want to delete.
0
 

Author Closing Comment

by:jb702
Comment Utility
Thanks...i figured as much..
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now