473,807 Members | 2,877 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access select field value AFTER a date

Question:
For a table like this:
Date | Description | Amount | Balance
9/25/04 | payment on acct | 25.00 | 0.00
10/1/04 | delivery | 54.25 | 54.25
11/5/04 | payment on acct | 54.25 | 0.00
11/10/04 | delivery | 48.57 | 48.57

Is there any way I can find the account balance on 11/1/04, when I
don't have an entry for 11/1/04?

I don't want to SELECT Balance WHERE (Date = #11/1/03#); because that
won't show anything for this customer. I don't want to SELECT Balance
WHERE (Date > #11/1/03#); because that will give me an entry for every
date after that, which is too much. You and I know that, for this
customer, I'd want to search on 11/5/04, but I need this for all
customers in the database, where this simple example limits it only to
one customer.

Any help would be appreciated!
Bill
Nov 13 '05 #1
2 5604
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Use a range of dates as parameters:

PARAMETERS [Start Date?] Date, [End Date?] Date;
....
WHERE ... [Date] BETWEEN [Start Date?] And [End Date?]

Try not to use the word "Date" as a column 'cuz it is a reserved word
and can sometimes be confused for the Date() function. To avoid that
confusion delimit the column name w/ square brackets.

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQaep3oechKq OuFEgEQIVtgCg0q VUvZmtjBQaOhKhV Se0OSGM6UgAnisN
mg6O5JGDZ7QwVsv G8wlVF42S
=xQGC
-----END PGP SIGNATURE-----
Bill wrote:
Question:
For a table like this:
Date | Description | Amount | Balance
9/25/04 | payment on acct | 25.00 | 0.00
10/1/04 | delivery | 54.25 | 54.25
11/5/04 | payment on acct | 54.25 | 0.00
11/10/04 | delivery | 48.57 | 48.57

Is there any way I can find the account balance on 11/1/04, when I
don't have an entry for 11/1/04?

I don't want to SELECT Balance WHERE (Date = #11/1/03#); because that
won't show anything for this customer. I don't want to SELECT Balance
WHERE (Date > #11/1/03#); because that will give me an entry for every
date after that, which is too much. You and I know that, for this
customer, I'd want to search on 11/5/04, but I need this for all
customers in the database, where this simple example limits it only to
one customer.

Nov 13 '05 #2
bi**@ehrhartpro pane.com (Bill) wrote in
news:b4******** *************** **@posting.goog le.com:
Question:
For a table like this:
Date | Description | Amount | Balance
9/25/04 | payment on acct | 25.00 | 0.00
10/1/04 | delivery | 54.25 | 54.25
11/5/04 | payment on acct | 54.25 | 0.00
11/10/04 | delivery | 48.57 | 48.57

Is there any way I can find the account balance on 11/1/04,
when I don't have an entry for 11/1/04?

I don't want to SELECT Balance WHERE (Date = #11/1/03#);
because that won't show anything for this customer. I don't
want to SELECT Balance WHERE (Date > #11/1/03#); because that
will give me an entry for every date after that, which is too
much. You and I know that, for this customer, I'd want to
search on 11/5/04, but I need this for all customers in the
database, where this simple example limits it only to one
customer.

Any help would be appreciated!
Bill
You will always run into problems with your structure. Balance
should always be calculated, and not stored. If you happen to
enter a transaction out of order, you're toast.

The better way is to calculate the running balance when you need
it as the sum of credits - sum of debits.
LedgerDate| Description | Amount | Credit
9/25/04 | payment on acct | 25.00 | true
10/1/04 | delivery | 54.25 | false


the query to return your balance on any date is

Select accountID, sum(amount*iif( credit,1,-1)) from ledger where
ledgerdate <= statementdate

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1935
by: Dan | last post by:
I hate it when people think that their own misunderstandings are bugs in the program, but this time I think I've got something. If I run the following SQL code in Access 2000, I get unexpected results: SELECT MY_FIELD FROM ( SELECT NULL AS MY_FIELD FROM DUAL
2
1684
by: Arif | last post by:
Very strange problem: Executing my query against MS Access database using OleDbProvider for Access, I am getting the value for first two columns '0' instead of '1' in DataGrid. But if I connect to SQL Server using OleDbProvider, it shows me the correct value i.e. 1 wherever it should be. To debug i write the query to a file. Now copy the query from that file to Acess SQL View and run. Here it shows the correct value 1 for the first two...
4
6415
by: alexandre.brisebois | last post by:
Hi, I am using access 2003, I would like to know if there is an option to reorganize the tables in a maner that is readable, as we can do in sql sever 2000 or 2005. I have been given a database to look a and I am loosing tremendious amounts of time trying to organize it so that I could view it. Regards, Alexandre Brisebois
4
1860
by: keithsimpson3973 | last post by:
Please forgive me for being so stupid. I have searched this site and many others for what should be a simple thing. I have a vb 6 form with a textbox that I input a date into. I can't set the format for the textbox on the vb6 form because it is a bound form using a data control. Here is the code I am using. The field in the Access Database "Date_In" is a date/time field I select "Date_In" from the first combo box, then I select "=" fron...
9
3949
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result - I have read every post out there and spent hours trying to figure out the problem with no success whatsoever - I have constrained the problem to one form however, and I think it's hiding somewhere in my code associated with this form, which is...
8
2907
by: saladinator | last post by:
I have created an Excel spreadsheet that has a lot of data. What I want to do is import the spreedsheet to Access and create a form so that I can print each row per page in a proffessional manner. The problem is that whenever I import the data to access my dates show up in 38478 instead of 05/06/05. How can I convert this number back to the date format in access?
8
6130
by: Killer42 | last post by:
Hi all. I have an interesting situation; searching a Date field for my exact value fails, but including it in a range works. I know this sounds like the usual beginner's date/time woes but I don't believe it is. The reason for the "Date/time precision" title is that I would like to know whether anyone can tell me to what precision a date/time value is stored in Access. And how it might be affecting my search. (I have spent some time...
1
19413
MMcCarthy
by: MMcCarthy | last post by:
Access has a number of built-in functions which can be generally used in queries or VBA code. Some of the more common ones are: Note: anything in square brackets is optional Date Functions Date() - Returns the current system date Now() - Returns the current system timestamp (date and time)
0
7673
MMcCarthy
by: MMcCarthy | last post by:
Rather than using the Access design view change the view to SQL. I am going to attempt to outline the general syntax used for SQL queries in Access. Angle brackets <> are used in place of some syntax elements you must supply. The description of these elements will be in the contained in the angle brackets. Square brackets are used to show which parts are optional. Basic SELECT query SELECT <field list> FROM <table/query name(s)>
1
6798
by: scubasteve | last post by:
Looking up values from an Access table is simple. Simulating the 'Range Lookup' functionality from Excel's VLookup formula is a bit trickier. For those that aren't familiar with this, it allows you to look up the next smallest value to what you provided, and return any corresponding field from the table. Very useful for looking up things like currency exchange rates, tax rates, etc., where there might not be an entry for every day/income...
0
9720
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10112
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6879
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3854
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.