Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 09-16-2004, 04:58 PM   #1 (permalink)
fdtoo
Registered User
 
Join Date: Aug 2004
Posts: 4
fdtoo is on a distinguished road
Question How to generate Calculated Field

I need to run a data report that will query an Access_Table that has the following Project info:

My Form has a command_button with the following code:

Private Sub Command1_Click()

Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=MSDataShape;Data PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Access_Table.mdb;"

Set adoAge = New Recordset

adoAge.Open "SELECT CustomerName, OrderNo, Invoice_Date, IIf([Invoice_Date]<Now()-30 And [Invoice_DATE]>Now()-60,[Invoice_Amount],"") AS Greaterthan30, IIf([Invoice_Date]<Now()-60,[Invoice_Amount],"") AS Greaterthan60 FROM Cust WHERE [Invoice_Date]< Now()-30", db, adOpenStatic, adLockOptimistic

Set DataReport1.DataSource = adoAge
DataReport1.Show

End Sub

My DataReport1 has the following RptTextbox:

RptTextbox Datafield
1 CustomerName
2 OrderNo
3 Invoice_Date
4 Greaterthan30
5 Greaterthan60

Problem arise when trying to display the above report that has an error message that says "Datafield Greaterthan30 not found"
Is this an SQL Query limitation where Invoice_Date Datafield can only be queried once & if we have more than one Datafield
with the same fieldname (Invoice_Date) within the same Data report,the report will fail to run? Should there be one more
New Recordset to hold a second Datafield (Invoice_Date)?

can anyone help? Thanks
From:Cady Steldyn
fdtoo is offline   Reply With Quote
Old 09-16-2004, 10:13 PM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,692
redhead is on a distinguished road
I took the liberty to move this thread, since I found it of very little use in the feedback section.

To me it looks like some VB program, but without the [ code][/ code] tags surrounding it I can't realy read the code that well.

Code:
... IIf([Invoice_Date]<Now()-30 And [Invoice_DATE]>Now()-60,[Invoice_Amount],"")
         AS Greaterthan30,
    IIf([Invoice_Date]<Now()-60,[Invoice_Amount],"") 
         AS Greaterthan60 ...
Thats the SQL-limitation, you are trying to fetch from the same field into two different arguments.

This sounds alot like some homework...
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL- Calculated Field fdtoo Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) 0 09-04-2004 12:37 AM
populate form field virtualGeorge PHP 4 08-23-2004 08:05 AM
Multiple Entry Fields for One Database Field heartsoh HTML, XML, Javascript, AJAX 0 07-12-2004 08:54 PM
How can I count characters in a text field? jimmyoctane PHP 2 10-18-2003 03:38 PM


All times are GMT -8. The time now is 07:37 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting