Charlotte Foust
charlotte.foust at gmail.com
Mon Jan 14 12:13:12 CST 2013
Rocky, Which record is not being deleted? You're doing two deletes, so does either one work? If not, do you have relationships defined in both front and back end? Are both tables in the back end or is one local? Are there any other relationships to tblCompany that might prevent the operation? Charlotte On Mon, Jan 14, 2013 at 9:51 AM, Rocky Smolin <rockysmolin at bchacc.com>wrote: > Dear List: > > I have an app generating the subject error when trying to delete a record. > I'm running this locally (FE and BE) and I'm the only one running it. > > The previous version of this app does not have the error. So something I > changed in the process of doing the client's latest wish list created it. > > I imported the opening form, main menu, and form that throws the error, and > a module of Public functions from the previous version which works and it > still generates the error. So it's not in those forms or module. > > (No unfortunately, I did not document each of my changes. :(((( ) > > the code is pretty simple: > > Private Sub cmdDelete_Click() > > On Error GoTo IsIt3200: > > intReply = MsgBox("Are you absolutely certain that you want to delete this > Company record?", vbYesNo) > If intReply = vbNo Then Exit Sub > > DoCmd.RunCommand acCmdDeleteRecord > > Me.cboCompanies.Requery > > Exit Sub > > IsIt3200: > > If Err.Number = 3200 Then > MsgBox "Company cannot be deleted as it is being used in one or more > Jobs/Bids", vbExclamation > Exit Sub > Else > MsgBox "Error: " & Err.Number & " - " & Err.Description > Call cmdExit_Click > End If > > End Sub > > trapping the condition if the company PK is an FK in any Job in tblJobs. > So > I tried using db.Execute like this: > > Private Sub cmdDelete_Click() > > On Error GoTo IsIt3200: > > intReply = MsgBox("Are you absolutely certain that you want to delete this > Company record?", vbYesNo) > If intReply = vbNo Then Exit Sub > > Set db = CurrentDb > db.Execute "Delete * FROM tblCompany WHERE CompanyID = " & Me.CompanyID > Me.Requery > > DoCmd.RunCommand acCmdDeleteRecord > > Me.cboCompanies.Requery > > Exit Sub > > IsIt3200: > > If Err.Number = 3200 Then > MsgBox "Company cannot be deleted as it is being used in one or more > Jobs/Bids", vbExclamation > Exit Sub > Else > MsgBox "Error: " & Err.Number & " - " & Err.Description > Call cmdExit_Click > End If > > End Sub > ' > > Generates no error but doesn't delete the record. > > Any ideas what I might have done to break my app? > > MTIA > > Rocky Smolin > Beach Access Software > 858-259-4334 > www.bchacc.com <http://www.bchacc.com/> > www.e-z-mrp.com <http://www.e-z-mrp.com/> > Skype: rocky.smolin > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com >