Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 12th, 2007, 03:05 PM
Authorized User
Join Date: Jun 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Comparinng Two Values from same table

Hello all,

I'm having a problem writing the last line for my where clause for my recordsource for access. I will omit the SELECT and FROM clauses because i know they work.

My where clause works up to this point:
" WHERE deceasedHolder.[Company ID] ='" & Me!Company_ID & "'" & _
    " AND deceasedHolder.[Next Put Date] = #" & Me!txtPutDate & "#" & _
The last "AND" should compare two values from the table deceasedHolder, which are deceasedHolder.[Quantity Approved] and deceasedHolder.Quantity, and return the fields where quantity approved is less than quantity. This is what I put down, but it is generating the error "You cancelled the previous operation.
    " AND deceasedHolder.[Quantity Approved] < deceasedHolder.Quantity;"
Any and all help is greatly appreciated.

Old June 12th, 2007, 04:06 PM
Friend of Wrox
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post

Is company_ID numeric?
Also, make sure that you separate with () the pieces so:

if you want to check this first:

" WHERE deceasedHolder.[Company ID] ='" & Me!Company_ID & "'" & _
    " AND deceasedHolder.[Next Put Date] = #" & Me!txtPutDate & "#" & _

you need to put () around it:

" ((WHERE deceasedHolder.[Company ID] ='" & Me!Company_ID & "'" & _
    " AND deceasedHolder.[Next Put Date] = #" & Me!txtPutDate & "#") & _
    " AND deceasedHolder.[Quantity Approved] < deceasedHolder.Quantity;)"

If you see the two (( at the beginning then 1 more that separates the first check, and a last ) to close the statement.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing Two values from same table MArgente BOOK: Beginning SQL 3 December 11th, 2009 07:35 AM
accessing table values in VB pettrer ASP.NET 2.0 Basics 1 April 22nd, 2006 09:58 AM
searching a table for values Nayt32 Access VBA 4 February 27th, 2006 11:19 AM
help - how to get different values from same table surajguru BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 4 July 22nd, 2005 12:39 PM
Adding 2 values in a table Regornil JSP Basics 2 September 13th, 2004 02:32 AM

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