PC Review


Reply
Thread Tools Rate Thread

How to generate Calculated Field

 
 
Cady Steldyn
Guest
Posts: n/a
 
      12th Sep 2004
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





*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      12th Sep 2004
Hi Cady,

"Cady Steldyn" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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)?


This is .net newsgroup :-)
Aynway, I would check for any typo.
Then I would check at debug time, the fieldnames of the recordset returned.
Just for the beginning :-)
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot table, IF function, calculated item versus calculated field NomadPurple Microsoft Excel Misc 1 9th Mar 2010 04:17 PM
Using the result of a calculated field in another calculated field's expression Paul Microsoft Access 1 12th Jan 2007 10:52 AM
Using the result of a calculated field in another calculated field's expression Paul Microsoft Access Queries 3 11th Jan 2007 05:53 PM
Criteria on field calculated form another calculated field Max Moor Microsoft Access Queries 1 22nd Dec 2004 09:19 AM
Need to Generate a calculated Field in Default Value =?Utf-8?B?Z2VuZWFuZGNsZW8=?= Microsoft Access Forms 2 20th Dec 2004 06:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:18 PM.