DoCmd to delete records


I have a command button that when clicked deletes certain records from
a subform based on an application number being equal. It deletes all
records with the same applciation number as currently shown on the
main form, see code below:

DoCmd.RunSQL ("DELETE FROM tblAdultDetails WHERE
[frmAdultDetails2].Form![ApplicationNum]=" +

However I would like it to only delete records if the fields
[MainApplicantFlag] =1 or [PartnerFlag] =1 as well as ApplicationNum
being equal. These are both number fields btw.

Can someone tell me what I should add to my code in order to do this?
I'm not sure of the syntax.


3/15/2007 2:24:21 PM
access.formscoding 7493 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 35

Answers in m.p.a.forms

Please do not post the same question repeatedly to different groups. If you 
must, post to several groups at once, so that any discussion is not 

3/15/2007 3:10:38 PM

Similar Artilces:

Can't delete old emails from Deleted items
I am having an issue on an Exchange 2000 server which was upgraded from Exchange 5.5 some time ago and 5.0 before that In outlook users get "Message cannot be deleted, the message was either moved or already deleted or access was denied It's only on messages from 1999 and earlier, anything newer can be deleted without a problem I have tried selecting many messages at a time and I have selected one message at a time It's not just one user that has the proble I've tried disabling all of my Antivirus stuff, I've taken ownership of the mailbox, I've tried on different co...

Delete Users!?!
My questions will surely sound stupid, but here we go : How do we delete a users in Microsoft CRM. It seam that none of the default Role as the right of deleting a users. Thank for folowing up, we are curently testing the product... Sorry David, but you can't delete users, only render them inactive, and revoke the license that you have applied against their account. "David Michaud" <> wrote in message news:87d001c43254$9dd83350$a001280a@phx.gbl... > My questions will surely sound stupid, but here we go : > How do we delete a...

archiving/deleting mailbox
In Exchange 2003, if I archive a mailbox, then delete the account and mailbox, is there a way to recover from the archive? what do you mean by "archive"? in Exchange 2003, if you have mailbox retention set, you can create a new account, then reconnect that account to the deleted mailbox... "Zakattack" <> wrote in message > In Exchange 2003, if I archive a mailbox, then delete the account and > mailbox, is there a way to recover from the archive? What I mean is...

How convert Docmd.Domenuitem
I'm converting a 97 db to 2000. A form has a button that executes a Docmd.Domenuitem command. This is supposed to invoke Find and Replace. It does, but the subject is grayed out. I need the find to be based on the control where the cursor was when the button was pressed. Any ideas? Access help in 2000 does not even mention this command neither does my Access book. Maybe you need to do Screen.PreviousControl.SetFocus DoCmd.RunCommand acCmdFind or DoCmd.FindRecord On Thu, 29 Sep 2005 13:43:03 -0700, "mscertified" <> wrote: >I'm converti...

Delete from server ?
Hi All I recently upgraded from OE6 to Outlook 2002 but cant seem to find a feature in OL that was really useful in OE. I have 1 particular account that I get a lot of junk mail on - my ISP (bless em) flags suspected junk mail by inserting the txt "Internet Spam" into the subject - you can then tell OE to delete messages that contain this flag directly from the server. The only similar rule in Outlook I can find is to "move to folder" and set this to Deleted Items. Unfortunately this means that the message gets downloaded - appears in the message window - then gets moved...

recipient policy/ not deleting old email
Hi all, I have been testing a 30 day email retention policy on exchange 2003 sp2, for Oultook 2003 inbox, sent items and deleted items folders. All test mailboxes are being processed but not all mail past the 30 day limit is being deleted. The biggest problem seems to be with removing old deleted items. We migrated email from groupwise to exchange a few months ago. Don't know if this is related. Thanks. Because of the migration, and other factors, the message dates for items might be different than you expect. Message age limit properties that are used by mailbox manag...

Stamp date for every record change
Hello! I need to know when and who made a change to a record. Is there an easy way to do this? The problem is that the data can be changed through both forms and queries, so programming the event for every form/query is impractical. Is there any 'global' event that fires when a record is saved or something? In Access 2010 (released later this month), you will be able to use Data Macros to do this. In current versions of Access, there's now way. -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users -

Delete open forms
Hello, I'm trying to write code that deletes all open unhidden forms... I have this code: Dim db As Access.Application Dim frm As Form Set db = Application For Each frm In db.Forms If frm.Visible Then DoCmd.Close acForm, frm.Name 'Debug.Print frm.Name End If Next frm Although the appropriate forms will print in the immediate window; the code will not delete them all. Strangely, the form that gets opened second seems to remain; i.e., if three forms are opened, the one that was opened first and last will close. Any thoughts? Thanks, al...

Is it true about DoCmd.SendObject
That DoCmd.SendObject will find your default Mail client? -- Thanks in advance for any help with this......Bob MS Access 2007 accdb Windows XP Home Edition Ver 5.1 Service Pack 3 "Bob Vance" <> wrote in message news:u91TwlG3KHA.4964@TK2MSFTNGP05.phx.gbl... > That DoCmd.SendObject will find your default Mail client? > > -- > Thanks in advance for any help with this......Bob > MS Access 2007 accdb > Windows XP Home Edition Ver 5.1 Service Pack 3 > > It's true if your default Mail client is Outlook :~) ...

How do I delete an archive folder?
In testing out the AutoArchive function, Outlook created an Archive Folders entry. I now have multiple Archive Folders entries showing as I changed where I wanted the archive stored. I would like to delete the unneeded archive. It contains no entries at this time. I have been unsuccessful in finding any method of removing the Archive Folders entry. I have checked the Help and searched through the online support knowledgebase. There does not seem to be any Delete command on any of the toolbar menus that is activated when an archive folder is selected. ...

Help with "Form DoCmd.Open and DoCmd.Close
The following two lines of code is not operating correctly. Private Sub cmdChangeVendor1_Click() DoCmd.Close acForm, "Invoice by Market Reviewer" DoCmd.OpenForm "Selections Vendor and Reviewer", acNormal End Sub When I click on the cmdChangeVendor1 button, I expect the form "Invoice by Market Reviewer" to close and the form "Selections Vendor and Reviewer" to open. But that is not the result I get. The form "Invoice by Market Reviewer" closes but that is about it. Nothing else opens. I have two forms that behaves this way. I have ...

Can't archive or delete emails in Outlook
Hi Folks, I'm running into a problem that is driving me batty. I have a pst file that I use to archive my email. The size of the file is 1.3Gb. It has been compacted, and I believe this was originally created with Outlook97. I'm currently using Outlook 2002. I'm trying to take this archive file and break it up into smaller files. I've created an archive file for each year (eg. archive2000.pst, archive2001.pst). When I try to archive the main file to one of these other files I receive an error. When I try to manually move or copy the email to one of these files I get th...

sub report won't show if no records are returned
Hi I have a report with a sub report. The parent report is grouped by month. The sub report is displayed for each month with the relevant records for that month. My problem is that if the sub report returns no records then the sub report won't show other controls that are on the sub report that are unrelated to the return of records ie labels. Does anyone have any ideas Cheers johnoxy wrote: >I have a report with a sub report. The parent report is grouped by month. >The sub report is displayed for each month with the relevant records for that >month. My problem is that if...

Word wrap macro deletes formula
I created a macro to wrap text on a protected worksheet in which each cell contains a formula importing text from another worksheet. The cells are locked and formulas hidden but when I run the macro, it wraps the text and deletes the formula> how can I stop it doing this? The macro is as follows: Sub Wordwrap() ' ' Wordwrap Macro ' Macro recorded 01/10/2004 ' ' Keyboard Shortcut: Ctrl+w ' With Selection .HorizontalAlignment = xlGeneral .VerticalAlignment = xlCenter .WrapText = True .Orientation = 0 .AddIndent = False ...

Adding/Updating a record in an SQL Server table using ODBC
Hi, This is a beginner's question. I tried to write an MFC aplication using SQL Server database as the back-end. I'm able to retrieve data from the required table but i'm unable to add/update records in the table as i'm getting a "Recordset read-only" error. What should I do? Is it required to add additional code to make it work? Please reply asap as this is part of my final year college project and time is running out. Thanks, Satish. check you have a primary key on the table. "Satish Chandrasekar" <

How do I append non-matching records
I want to append records to tableB only when the key field in tableA does not match the key field in tableB Omi We're not there. We can't see your tables or relationships. Are you saying that you have two tables with identical structure, and you're adding to one table only if the record isn't already in another table? If so, why?! In a well-normalized relational database, you usually don't need/have multiple tables with the same structure. More info, please... Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have recei...

Problems deleting from the DELETE ITEMS & JUNK MAIL folders
Hi, Cannot delete certain messages from the DELETE ITEMS & JUNK MAIL folders. Why is that and how can I overcome this please? -- Kind regards, ColUCol How to Remove a Stuck Undeletable Message in Windows Mail WMUtil -- Bruce Hagen MS-MVP [Mail] Imperial Beach, CA "colucol" <> wrote in message > Hi, > > Can...

Avoiding Reference errors when deleting and adding new worksheets
I have several worksheets that compile and summarize the data from different bond deals which each have their own worksheet. (In example, I have worksheets named Combined, Outstanding, and Capacity that sum the numbers from worksheets Issue A, Issue B, Issue C etc.) I would like to be able to delete and add new bond deal worksheets without having to change the formulas on the other worksheets. Can anyone please suggest a function or way to set up the summary worksheets up that won't give me #REF! errors everytime I delete and add in a new bond deal worksheet? I appreciate any help. Th...

HOW TO DELETE A PICTURE I HAVE INSERTED IN EXCEL SHEET.NO WHERE IN EDIT BUTTONOR IN SHORT CUT MENU DELETE COMMAND FOUND. Probably isn't the right way to do it but, I usually just cut and paste the picture in another spreadsheet then delete the sheet. Larry -- keithl816 ------------------------------------------------------------------------ keithl816's Profile: View this thread: FIRST . Please don't shout by typing in all caps. It is considered very...

What to do with 1.5 million records...
So my company just bought another company and they send me a flat text file with 1.5 million records of customer name/orders/transactions etc - all in one huge txt file. Just for fun... I imported this into Access 2007 and you can view the single table, can't do anything with it, a simple parameter search on one customer name locks up the server, Access not responding, white screen blah, blah blah... I tired to split the table during import with the wizard to create the 6 or so tables I would like to have - but it kept bombing out. When I tried a small sample I see I get p...

When I close a form with DoCmd.Close I get a parameter popup
This is a repost. I will try to explain the problem a little better than I did the last time. When I execute DoCmd.Close on one of my forms I get one of those little unknown parameter popups, the kind you get when there's something wrong with your query. But all I'm trying to do is close the form, not read any data. This popup appears to be gernerated by the row source query in a list box on the form. This row source query references another text box on the form and this appears to be what the popup is asking for. But there's a value in this text box. And why should th...

How to delete unneeded colums in a sheet
I created a book for creditcard management and I need only so much colums. How to delete the other colums? ervinke -- Highlight the columns you don't wish to see and do Right-click > Hide Vaya con Dios, Chuck, CABGx3 "erwinke" wrote: > I created a book for creditcard management and I need only so much colums. > How to delete the other colums? > > ervinke > -- If this is something you have to do frequently, you might check out Jim Cone's fine commercial Add-in called "Special Sort". It's available at

Create a button to find the next record
Hi I am trying to create a button to find the next record for a particular studentID. There is a main form and subform. I want to be able to find all relevent subforms for a particular student. The master link id is STUDENTID and the child link id is STUDENTID_FK. So for student #1, when I click on the subform and click on the button, it would cycle through all this student's records. What is the best way to set up this button? Thank you for your help in advance. You already have one that is built in. Just click the navigation button right of the record number ...

Need Help with 140,000 Records
Our problem is we have 6 XL spreadsheets that have a total of 140,000 records. Each record has a control number and we need to combine all the records or be able to look across all the records to verify that they are within a certain time frame and also delete duplicates. There are 400 duplicate control numbers that we need to search for across the 6 spreadsheets. Let me know if this is not enough info. Thanks for any of your help. Kris, You'll be able to do it with Excel 2007, as it has about a million rows. Excel 2003 and back have only 64K. With those, you'd have to jump th...

Deleting Non-Duplicate Rows
Have done tihs is the past, but can't remember how: Have a sheet with 9500+ rows. Column C contains a storage bin number. Want to delete all rows that DO NOT have a duplicate (trying to resolve items that have a duplicate bin number.) Have sorted the sheet on Column C. THX. . . -- BillW ------------------------------------------------------------------------ BillW's Profile: View this thread: You could use a helper column of formulas: =countif(c:c,c1)...