473,396 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Referring to a Calculated Field in a Recordset

Greetings,

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

and then I try to use this calculated field:

If rsGPValue.Fields("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 3590
* ey*******@iname.com:
Greetings,

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

and then I try to use this calculated field:

If rsGPValue.Fields("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.OpenRecordset("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.OpenRecordset("SELECT *,
DateSerial(Year([ValueDate]),Month([ValueDate])+4,0) FROM tblGPValue AS
OurDate, dbOpenSnapshot)

and then I try to use this calculated field:

If rsGPValue.Fields("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.OpenRecordset("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
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...
1
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...
4
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
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...
4
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...
11
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...
5
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...
2
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...
1
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)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.