Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 7th, 2010, 07:10 PM
Registered User
Join Date: Apr 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Delete Query using IF statement

The problem I am having is that, the if statement does not seem to be correct as it’s not actually checking to match up a claim # for one table and matching it to another. If there is a match then it’s supposed to run a delete query to remove all these matches. If there is a discrepancy it’s supposed to preview the claims that the claim # does not match up

Private Sub Delete_Claim_CMD_Click()
'matches records and deletes ones that have been inputted into the Customer Return Database
Dim stDocname As String
stDocname = "RptAllCustRet"
'Matches up claim number on the master list and the OP Customer returns
If [tbl_master_data]![RPT_CLAIM_NO] = [TblAllCustRet]![RPT_CLAIM_NO] Then
'Runs the query to delete all non matching / missing / complete claims
DoCmd.OpenQuery (DeleteClaim)
ElseIf [tbl_master_data]![RPT_CLAIM_NO] <> [TblAllCustRet]![RPT_CLAIM_NO] Then
' Opens the report to show the incomplete claims
DoCmd.OpenReport stdDocName, acPreview
End If

End Sub

My delete query works but it removes all fields once run

Also one more thing since I am at it
I am looking for a command line that will do this
Query to find a field “metric flag” ‘M’ and a weight  done
Now I want to convert this weight only flagged with the “M”
If Metric_Flag = “M” then Bundle_Weight = Bundle_Weight*2.20
Is this possible?
Reply With Quote
  #2 (permalink)  
Old April 9th, 2010, 08:07 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG

By looking at your code, I see a lot of potential problems.

First, where is this code located? It looks like it's a button on your form called Delete_Claim_CMD. It also looks like the code is run when someone clicks on the button.

If so, which table is the record source for your form? Is it tbl_master_data or TblAllCustRet or something else or nothing (an unbound form)?

Which tables are open at the time the person clicks the button? Is there another form open that has another table as its record source? Is the code you posted mentioning tables that are not open by any form at all at the time the user clicks the button?

Putting a criteria in your query in the claim number field mentioning any open form's record's claim number value will also simplify the code. But I'd have to know which form is open when the query is run.

The answers to these questions will determine what your code should look like.
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
php/mysql delete button and delete query dungey PHP Databases 17 April 11th, 2009 12:24 PM
problem with delete statement thas123 SQL Server 2000 6 March 23rd, 2006 01:13 PM
Delete Statement Error Jane SQL Language 1 October 21st, 2005 01:45 PM
T-SQL Delete statement Alcapone C# 3 November 3rd, 2004 01:08 PM
sql delete statement sand133 VB Databases Basics 2 July 7th, 2004 10:56 PM

All times are GMT -4. The time now is 08:46 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.