Solved

Access2010 Form Delete Issue

Posted on 2013-11-02
4
468 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 48

Accepted Solution

by:
Dale Fye 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

630 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