Re: referring previous record of recordset from within sql statement
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Sun, 15 Oct 2006 14:35:56 -0400
shripaldalal wrote:
now instead of doing all this cant this be doine in the sql statementI was intrigued so i started playing with this.
itself ??? the main purpose is to make the program smaller because
there are lots of such statements in the reports.... makin arrays and
such if then statements code blows up alarmingly.....
If you add an autonumber field to your table (call it doc_id and make it the
primary key; create a non-unique index on the document_no field as well),
you can do something like this:
Create a saved query called PriorDocuments with this sql:
Select [doc_id] + 1 As PriorDoc_id, document_no From accounts
Then use this sql statement to retrieve your records:
Select IIf([p].[document_no] Is Null,[c].[document_no],'') AS document_no,
document_date, ledger_ac, debit, credit
From accounts c left join PriorRecord p ON c.document_no= p.document_noAND (c.doc_id= p.PriorDoc_id)
I only did this as an intellectual puzzle. I still believe this method
should not be used in production. However, it is your application ...
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
.
- References:
- referring previous record of recordset from within sql statement
- From: shripaldalal
- Re: referring previous record of recordset from within sql statement
- From: Bob Barrows [MVP]
- Re: referring previous record of recordset from within sql statement
- From: shripaldalal
- Re: referring previous record of recordset from within sql statement
- From: Bob Barrows [MVP]
- Re: referring previous record of recordset from within sql statement
- From: shripaldalal
- referring previous record of recordset from within sql statement
- Prev by Date: Re: referring previous record of recordset from within sql statement
- Next by Date: advanced telesoft dan
- Previous by thread: Re: referring previous record of recordset from within sql statement
- Next by thread: advanced telesoft dan
- Index(es):
Relevant Pages
|