473,394 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 5582
-----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:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQaep3oechKqOuFEgEQIVtgCg0qVUvZmtjBQaOhKhVSe0OS GM6UgAnisN
mg6O5JGDZ7QwVsvG8wlVF42S
=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**@ehrhartpropane.com (Bill) wrote in
news:b4*************************@posting.google.co m:
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
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...
2
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...
4
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...
4
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...
9
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...
8
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....
8
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...
1
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 ...
0
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.