Solved

Access2010 Form Delete Issue

Posted on 2013-11-02
4
450 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
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…

821 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