Solved

Access2010 Form Delete Issue

Posted on 2013-11-02
4
439 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
ID: 39619497
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
ID: 39619512
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
ID: 39619780
"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
ID: 39620230
Thanks...i figured as much..
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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.

864 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

21 Experts available now in Live!

Get 1:1 Help Now