473,775 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Referring to a Calculated Field in a Recordset

Greetings,

in A2K VBA, I set the following recordset:
Set rsGPValue = dbs.OpenRecords et("SELECT *,
DateSerial(Year ([ValueDate]),Month([ValueDate])+4,0) FROM tblGPValue AS
OurDate, dbOpenSnapshot)

and then I try to use this calculated field:

If rsGPValue.Field s("OurDate") > {Forms]![frmReport]![RepDate].Value
Then [...more code to which the compiler never gets]

I get the "item not found in this collection" error. I verified that
the problem is with this created field (with a temp variable). A query
with this calculated field creates it just fine, and I can use it. Do I
refer to a calculated field in a recordset differently from a "natural"
field?

Thanks,
Yisroel

Jun 5 '06 #1
2 3618
* ey*******@iname .com:
Greetings,

in A2K VBA, I set the following recordset:
Set rsGPValue = dbs.OpenRecords et("SELECT *,
DateSerial(Year ([ValueDate]),Month([ValueDate])+4,0) FROM tblGPValue AS
OurDate, dbOpenSnapshot)

and then I try to use this calculated field:

If rsGPValue.Field s("OurDate") > {Forms]![frmReport]![RepDate].Value
Then [...more code to which the compiler never gets]

I get the "item not found in this collection" error. I verified that
the problem is with this created field (with a temp variable). A query
with this calculated field creates it just fine, and I can use it. Do I
refer to a calculated field in a recordset differently from a "natural"
field?

Thanks,
Yisroel


If OurDate is supposed to be an alias for the calculated field, I think
you have the "AS" in the wrong place.

Set rsGPValue = dbs.OpenRecords et("SELECT *,
DateSerial(Year ([ValueDate]),Month([ValueDate])+4,0) AS
OurDate FROM tblGPValue" , dbOpenSnapshot)

--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
Jun 5 '06 #2
Randy Harris wrote:
* ey*******@iname .com:
Greetings,

in A2K VBA, I set the following recordset:
Set rsGPValue = dbs.OpenRecords et("SELECT *,
DateSerial(Year ([ValueDate]),Month([ValueDate])+4,0) FROM tblGPValue AS
OurDate, dbOpenSnapshot)

and then I try to use this calculated field:

If rsGPValue.Field s("OurDate") > {Forms]![frmReport]![RepDate].Value
Then [...more code to which the compiler never gets]

I get the "item not found in this collection" error. I verified that
the problem is with this created field (with a temp variable). A query
with this calculated field creates it just fine, and I can use it. Do I
refer to a calculated field in a recordset differently from a "natural"
field?

Thanks,
Yisroel


If OurDate is supposed to be an alias for the calculated field, I think
you have the "AS" in the wrong place.

Set rsGPValue = dbs.OpenRecords et("SELECT *,
DateSerial(Year ([ValueDate]),Month([ValueDate])+4,0) AS
OurDate FROM tblGPValue" , dbOpenSnapshot)


Duh :-) That was it, and the compiler didn't complain of SQL syntax. I
really shouldn't code late at night...

Many thanks, Randy!

Jun 5 '06 #3

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

Similar topics

5
29848
by: Simone | last post by:
Hello I hope you guys can help me. I am very new to ADO... I am creating a ADODB connection in a module and trying to access it from a command button in a form. Function fxEIDAssgn(plngEID As Long) As Boolean Dim rsAssignedUser As ADODB.Recordset Dim strSelectUser As String
1
2346
by: Norbert Lieckfeldt | last post by:
MS Access 2002 here. I am just trying to set up a simple database for a friend who's an optician. Basically, all clients with address details, date of last eyetest and a drop-down combo box to choose a number of months to the next eyetest (3,6,12,24). I then have a calculated field in the form which works out the date of the next appointment on the basis of the previous two sets of information . All that works . I am now trying to set...
4
2319
by: Won Mee | last post by:
I want to enter a value in a field and for that value that was entered to be multiplyed by 10 and then stored in a table. How do I do this? For example: =*10; Thanks, Won Mee
2
2147
by: Zlatko Matić | last post by:
I have a field and want to have a calculated field in a report that counts it. It had control source set to "=count (). As can be also Null, I would like it to count only values distinct from Null. I tried by "Control Source=Count( Is Not Null), but it doesn't work, it still counts all rows, even with Null. How to set Control Source in the calcualted text box, in order to count only values that are not null? Thanks,
4
2441
by: bpneary1 | last post by:
First of all, I want to thank everyone who posts messages in this group. I am very new to VB and developing full-blown database apps, and I have learned a great deal by reading these posts, so I am very grateful. I have a problem that I have been working on, and I was wondering if anyone had a simple solution. I have a table of data similar to the example shown below:
11
2359
by: James Hallam | last post by:
I have read through all the past topics and couldn't find what I was after so... I am looking to store some calculated values (don't flame just yet, just read on!). I have an piece of code behind a form which calculates a percentage completion and an expected completion date of a job. I would like to store this information in a separate table, along with the actual date the values were calculated. Whenever a job is completed I can...
5
5887
by: Henrik | last post by:
The problem is (using MS Access 2003) I am unable to retrieve long strings (255 chars) from calculated fields through a recordset. The data takes the trip in three phases: 1. A custom public function returns a long string. This works. 2. A query has a calculated field based on the custom function above. This works when the query is run directly.
2
5545
by: jcf378 | last post by:
hi all. I have a form which contains a calculated control ("days") that outputs the # of days between two dates (DateDiff command between the fields and ). However, when I click "Filter by Form" in order to search for records based on this form, I would like to be able to enter a value in this "days" control so that I can filter records on the form based on this calculated interval (i.e., i want to search for records specifically where...
1
1526
by: manager | last post by:
I want to be able to use DLookup in a query, extracting a value from a Table to form a new field in the query. For interest, I have a record of Beetle sightings and record a unique number (J) for each species. I have a table that defines Beetle families as those that belong to the set J(lowest) and J(highest). eg the Family A consists of all beetles with numbers between 5 and 1500.
0
9623
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10111
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8943
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5365
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5488
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4023
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3615
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2855
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.