473,406 Members | 2,633 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,406 software developers and data experts.

Undefined function 'PrevRecVal' in expression.

7
My query contains a field called TotalIn, which returns number data from an underlying table. I have modified a function, PrevRecVal, which returns the datum form the previous record in the TotalIn field and places it into a field called PrevTotalIn. To accomplish this I inserted, into the query, a new field containing the expression referencing the function. I ran the query and it returned the desired result. However, I then saved the module and the mdb file tried to run the query again and got the "Undefined function 'PrevRecVal' in expression." What is happening in the save operation to give this error? Thanks.
Jan 30 '07 #1
8 5324
ADezii
8,834 Expert 8TB
My query contains a field called TotalIn, which returns number data from an underlying table. I have modified a function, PrevRecVal, which returns the datum form the previous record in the TotalIn field and places it into a field called PrevTotalIn. To accomplish this I inserted, into the query, a new field containing the expression referencing the function. I ran the query and it returned the desired result. However, I then saved the module and the mdb file tried to run the query again and got the "Undefined function 'PrevRecVal' in expression." What is happening in the save operation to give this error? Thanks.
Is the Function declared Publically as opposed to Privately?
Jan 30 '07 #2
Wade
7
My function statement reads: Function PrevRecVal (Keyname As String, Keyvalue, FieldNameToGet As String).

I am confused by the sentence in "Microsoft Access 2003 Inside Out": "Use the Public keyword to make this function available to all other procedures in all modules". I want the function to be available to my expression within my query! Translate, please. I have a lot to learn, yet, in MSAccess. Thanks.
Jan 30 '07 #3
ADezii
8,834 Expert 8TB
My function statement reads: Function PrevRecVal (Keyname As String, Keyvalue, FieldNameToGet As String).

I am confused by the sentence in "Microsoft Access 2003 Inside Out": "Use the Public keyword to make this function available to all other procedures in all modules". I want the function to be available to my expression within my query! Translate, please. I have a lot to learn, yet, in MSAccess. Thanks.
In order for a Function to be available within an Expression in an Access Query it 'must' be declared Public in a Standard, (not Form), Code Module. e.g.
Expand|Select|Wrap|Line Numbers
  1. Public Function PrevRecVal (Keyname As String, Keyvalue, FieldNameToGet As String)
It must also be passed the correct number and Data Types of Arguments as defined in its Declaration. e.g.
PrevRecVal must receive 2 Strings
Jan 30 '07 #4
NeoPa
32,556 Expert Mod 16PB
My function statement reads: Function PrevRecVal (Keyname As String, Keyvalue, FieldNameToGet As String).

I am confused by the sentence in "Microsoft Access 2003 Inside Out": "Use the Public keyword to make this function available to all other procedures in all modules". I want the function to be available to my expression within my query! Translate, please. I have a lot to learn, yet, in MSAccess. Thanks.
When a query is run, it is processed by the SQL engine or interpreter. As such, it is not part of any form or report or any database object. It is therefore not local to any modules and is only able to reference globally available (As ADezii has explained) and built-in procedures (functions and subroutines).

Even if you execute a SQL command from within a form's module, that SQL executes in the SQL engine and cannot access anything locally in the form. Does this help to understand why this is as involved as it is?
Jan 30 '07 #5
Wade
7
Yes, that is the just the type of explanation I need. So, when the term "form" is used, does that specifically mean the MS Access Form object or are Tables, Queries, Forms and Reports all considered, generically, forms. Also, just what is a module? What must a module consist of and what all can be included in a module? Thank all of you for your responses. I'm sure all this will become more clear as I study MS Access further. Jeez, I hope these aren't too basic questions for this forum.
Jan 30 '07 #6
NeoPa
32,556 Expert Mod 16PB
  1. The term 'form' would refer to an MS Access form.
  2. Tables; Queries (QueryDefs); Reports; Forms are all objects in an Access database.
  3. A module is a container for program code. There are three types
    1. General purpose modules
    2. Object modules (for code in Forms or Reports)
    3. Class Modules - more complicated - support defining classes.
HTH.
Jan 30 '07 #7
Is the problem simply that this was a function in Access 97 but does not seem to work in latter versions. I have copied this from an old access version and it still works fine using the earlier version of access.

Previous Odometer: PrevRecVal("ID",[ID],"Odometer") this simply returns the Odometer value from the previous row.

This was actually taken from a query from the free access download Qrysmp97.mdb from Microsoft.

Hope this helps.
Jul 5 '07 #8
NeoPa
32,556 Expert Mod 16PB
No. I'm afraid not.
If you read through the thread you will see the reason explained quite fully and clearly :)
Let me know if you have any problem understanding the explanations.
Jul 5 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mantorok Redgormor | last post by:
In this context would an indeterminate value lead down the path to undefined behavior? (void)foo->member; I want to keep my interface consisent in my program so I have this one function which...
12
by: RoSsIaCrIiLoIA | last post by:
On Mon, 07 Feb 2005 21:28:30 GMT, Keith Thompson <kst-u@mib.org> wrote: >"Romeo Colacitti" <wwromeo@gmail.com> writes: >> Chris Torek wrote: >>> In article <4205BD5C.6DC8@mindspring.com> >>>...
10
by: Michael B Allen | last post by:
I have some code: *str++ = tolower(*str); that gcc is complaining about: warning: operation on `str' may be undefined I'm getting similar warnings for 'di' and 'bi' in:
14
by: avsharath | last post by:
In "Bjarne Stroustrup's C++ Style and Technique FAQ" at: http://www.research.att.com/~bs/bs_faq2.html#evaluation-order for the statement: f(v,i++); he says that "the result is undefined...
45
by: VK | last post by:
(see the post by ASM in the original thread; can be seen at <http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/3716384d8bfa1b0b> as an option) As that is not in relevance to...
2
by: Wade | last post by:
I am pretty new to Access, especially writing code, but I found code on the web to do just what I want and it is posted below. It returns a field value from a previous record. I found the code at:...
12
by: Rajesh S R | last post by:
Can anyone tell me what is the difference between undefined behavior and unspecified behavior? Though I've read what is given about them, in ISO standards, I'm still not able to get the...
33
by: coolguyaroundyou | last post by:
Will the following statement invoke undefined behavior : a^=b,b^=a,a^=b ; given that a and b are of int-type ?? Be cautious, I have not written a^=b^=a^=b ; which, of course, is undefined....
8
by: Aftabpasha | last post by:
In a function call like printf("%d,..",++i,++i,..) can we consider every ++i as a Full Expression? And if it is a full expression, it means there is a sequence point after every ++i. So,...
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: 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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.