472,958 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

need help writing some code in an access query

I really need some help

Date Code ConCAT Bal_Fwd NS_Fees Amt_Coll Cur_End_Bal
1/15/2004 KW 11KW2003 $500.00 $250.00 $250.00
2/15/2004 KW 12KW2003 $300.00 $500.00 -$200.00
3/15/2004 KW 1KW2004 ???? $123.00 $584.00 -$461.00
4/15/2001 KW 2KW2004 XXXX $223.00 $484.00 -$261.00
1/15/2004 SO 11O2003 $300.00 $250.00 $50.00
2/15/2004 SO 12SO2003 $300.00 $500.00 -$200.00
3/15/2004 SO 1SO2004 ---- $123.00 $584.00 -$461.00

This is what I have in my query showing.
What I need help doing is: the spot where the ????, ---- and XXXX are
in the Bal_Fwd column, I need the value showing in the Cur_End_Bal
column, but is has to be from two months before. Always two months
prior. So... the ???? should show $250.00 and the XXXX should show
-$200.00 and the ---- should show $50.00. (The reason that the other
bal_fwd are blank is cause there are no records 2 months previous.)
What kind of code should I use in the query? The query name is
"qryAR" and the Cur_End_Bal is calculated (NS_Fees - Amt_Coll).
What should I do, I am stuck????
THank you
Paul Mendez
Nov 12 '05 #1
2 3458
It looks like you need to use the following formulae:

iif([bal_fwd]='????', dlookup("[bal_fwd]", "[tbln]", "[tbln]![Date]=#" &
dateadd("m", -2, [date]) & "#", [bal_fwd])

please read the help on
iif function
dlookup function
dateadd function

idea is if ???? then lookup value where date = date - 2 months...
"Paul Mendez" <pm*****@thelyndco.com> wrote in message
news:99**************************@posting.google.c om...
I really need some help

Date Code ConCAT Bal_Fwd NS_Fees Amt_Coll Cur_End_Bal
1/15/2004 KW 11KW2003 $500.00 $250.00 $250.00
2/15/2004 KW 12KW2003 $300.00 $500.00 -$200.00
3/15/2004 KW 1KW2004 ???? $123.00 $584.00 -$461.00
4/15/2001 KW 2KW2004 XXXX $223.00 $484.00 -$261.00
1/15/2004 SO 11O2003 $300.00 $250.00 $50.00
2/15/2004 SO 12SO2003 $300.00 $500.00 -$200.00
3/15/2004 SO 1SO2004 ---- $123.00 $584.00 -$461.00

This is what I have in my query showing.
What I need help doing is: the spot where the ????, ---- and XXXX are
in the Bal_Fwd column, I need the value showing in the Cur_End_Bal
column, but is has to be from two months before. Always two months
prior. So... the ???? should show $250.00 and the XXXX should show
-$200.00 and the ---- should show $50.00. (The reason that the other
bal_fwd are blank is cause there are no records 2 months previous.)
What kind of code should I use in the query? The query name is
"qryAR" and the Cur_End_Bal is calculated (NS_Fees - Amt_Coll).
What should I do, I am stuck????
THank you
Paul Mendez

---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.687 / Virus Database: 448 - Release Date: 16/05/2004
Nov 12 '05 #2
"Paul Mendez" <pm*****@thelyndco.com> wrote in message
news:99**************************@posting.google.c om...
I really need some help

Date Code ConCAT Bal_Fwd NS_Fees Amt_Coll Cur_End_Bal
1/15/2004 KW 11KW2003 $500.00 $250.00 $250.00
2/15/2004 KW 12KW2003 $300.00 $500.00 -$200.00
3/15/2004 KW 1KW2004 ???? $123.00 $584.00 -$461.00
4/15/2001 KW 2KW2004 XXXX $223.00 $484.00 -$261.00
1/15/2004 SO 11O2003 $300.00 $250.00 $50.00
2/15/2004 SO 12SO2003 $300.00 $500.00 -$200.00
3/15/2004 SO 1SO2004 ---- $123.00 $584.00 -$461.00

This is what I have in my query showing.
What I need help doing is: the spot where the ????, ---- and XXXX are
in the Bal_Fwd column, I need the value showing in the Cur_End_Bal
column, but is has to be from two months before. Always two months
prior. So... the ???? should show $250.00 and the XXXX should show
-$200.00 and the ---- should show $50.00. (The reason that the other
bal_fwd are blank is cause there are no records 2 months previous.)
What kind of code should I use in the query? The query name is
"qryAR" and the Cur_End_Bal is calculated (NS_Fees - Amt_Coll).
What should I do, I am stuck????

select q.[Date], q.Code, q.ConCAT,
(
select q2.Cur_End_Bal
from qryAR as q2
where q2.Code = q.Code
and q2.[Date] = DateAdd("m", -2, q.[date]
) as Bal_Fwd,
q.NS_Fees, q.Amt_Coll, q.Cur_End_Bal
from qryAR as q
order by q.Code, q.[date]






Nov 12 '05 #3

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

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
6
by: ti33m | last post by:
Hi All, I'd like to include a datasheet on my user interface but since I'm starting to run tight on space, I'd like to have a vertically-oriented datasheet (column 1 has labels, column 2 has...
3
by: pw | last post by:
Hi, I am having a mental block trying to figure out how to code this. Two tables: "tblQuestions" (fields = quesnum, questype, question) "tblAnswers" (fields = clientnum, quesnum, questype,...
1
by: Paul Mendez | last post by:
I really need your assistance. I tried what you gave me and it did not work and I am thinking that the formatting that showed up when u saw my posting might have confused you. So I made sure to...
3
by: ssb | last post by:
Hello, This may be very elementary, but, need help because I am new to access programming. (1) Say, I have a column EMPLOYEE_NAME. How do I fetch (maybe, cursor ?) the values one by one and...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
3
by: Michael D. | last post by:
Hello all! I'm trying to design and write a little application for someone in my office, but I'm having some trouble. I have the following database structure (Note: just some sample data,...
9
by: Blarneystone | last post by:
Hi, I am using VB.NET and trying to pull data from two different tables in the database. I am using what I think is standard code. But the data I am pulling is like the following: Table1...
8
by: Lykins | last post by:
We currently use Access 2003 in our company and have had this issues from every version from Access 97 to 2003. We deal with large databases and run a lot of queries over tables with millions of...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.