VBA Constant In Sql Is It Only Evaluated Once?

Aug 13, 2007

Hi at the moment I am using a bit of VBA code like below:

Public Const currentYear As String = "0708"

Static Function GetCurrentYear()
GetCurrentYear = currentYear
End Function

I then call this from my ms access sql statement with GetCurrentYear() am I correct in thinking this will only need to be evaluated once (I am just thinking in terms of performance) as it is a static function and a constant or is there a quicker way to do this. I couldn't see a way to easily get the value from a constant without a function. I may be missing something though thanks for any advice.

View Replies


ADVERTISEMENT

Expression Too Complex To Be Evaluated?

May 23, 2007

The control source for the Activity Summary report in my DB is the primary data table. The report contains about 12 fields, each with a statement like this one as its control source: =Sum(Abs(Year([RecDate])=Year(Date()) And ([NotifType]=9)))

Up until yesterday afternoon the report was working just fine. But suddenly when I run the report I'm getting this error:

"The expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables."

I have no idea why this problem suddenly popped up when the report had been running just fine for weeks.

Here's what I've done so far to try and fix it:
1. Copied the report and gave it a new name, thinking if the report were somehow corrupt creating a new one might fix it. No such luck.
2. Tried running the report after removing each control source statement one-by-one, but the error didn't disappear until all the statements had been cleared.

Anyone have any ideas? I'm willing to post the DB if that will help.

View 2 Replies View Related

Queries :: Too Complex To Be Evaluated

Dec 2, 2014

I have 4 queries that run and prepare a temporary table for which I then have a sales report generated . THis report has been active for over a year exactly as is but now the past week I am getting an error message that says "The expression is typed incorrectly or is too complex to be evaluated".I used the query designer in access to create them, here they are in SQL VIEW

My Make Table Query:

SELECT [Job Table].[Job Number], [Job Table].[Date Sold], Commission.originalCRate, Customers.[Last Name], [Job Table].Salesperson, [Job Table].Split, [Job Table].[Job Type], Commission.SaleAmount, Commission.JobCost, Commission.SPR INTO [New Sales Report Temp Table]
FROM (Customers LEFT JOIN [Job Table] ON Customers.[client id] = [Job Table].[Client id]) LEFT JOIN Commission ON [Job Table].[Job Number] = Commission.[Job Number]
WHERE ((([Job Table].[Date Sold])>#12/31/2012#) AND (([Job Table].Split)=No));

Query 2:

INSERT INTO [New Sales Report Temp Table] ( [Job Number], [Date Sold], [Last Name], Split, SaleAmount, Salesperson, [Job Type], OriginalCRate, SPR, JobCost )
SELECT [Job Table].[Job Number], [Job Table].[Date Sold], Customers.[Last Name], [Job Table].Split, [saleAmount]*[SPr] AS TotalSale4, [Job Table].Salesperson, [Job Table].[Job Type], Commission.OriginalCRate, Commission.SPR, [jobCost]*[SPR] AS JCost
FROM (Customers LEFT JOIN [Job Table] ON Customers.[client id] = [Job Table].[Client id]) LEFT JOIN Commission ON [Job Table].[Job Number] = Commission.[Job Number]
WHERE ((([Job Table].[Date Sold])>#12/31/2012#) AND (([Job Table].Split)=Yes));

[code]...

When I run the queries as a query and view data in datasheet they all work, however when I run the report I get the error message.My Access DB is a front end connected to an SQL server backend. I have never created queries in SQL just in Access.

View 1 Replies View Related

Using A Constant

Sep 27, 2006

Hi

Newbie question, here.

I have a table T_RollDate
It only has one field, called RollDate
It only has (and only ever has) one record (being a date)

I also have a form F_RollDate that has T_RollDate as record source, containing a text box that has RollDate as the control source.

It has been suggested to me that I can interrogate the value of the record in T_RollDate as if it were a constant, and use that constant in (eg) other select queries. To be precise, I was told that
forms!F_RollDate!RollDate
would return the value of that record.

I cannot get this to work (assuming that it should be possible). If I refer to forms!F_RollDate!RollDate in an query then when I run the query I am prompted to enter a parameter value for forms!F_RollDate!RollDate, where I had hoped that it would select the value of the only record in T_Rolldate.RollDate.

Any pointers would be much appreciated.

View 2 Replies View Related

This Expression Is Typed Incorrectly, Or Is Too Complex To Be Evaluated

Aug 16, 2006

Hey guys,

I am getting this error "This expression is typed incorrectly, or is too complex to be evaluated"

For this query:
SELECT first([TblProp].[Name]) AS [SName], First([TblProp].[CommentDate]) AS DateCommented, First([TblProp].[No]) AS BNum, First([TblProp].[Indication]) AS Ind, First([TblProp].[PropSubmitted]) AS DateSub, First([TblProp].[Contact]) AS PrimCon, First([TblProp].[Prepared]) AS PrepName, First([TblProp].[Comment]) AS Comment,First([TblProp].[Value]) AS ValueNew, First([TblProp].[Rating]) AS Prob
FROM TblProp
GROUP BY [TblProp].[RFPNo];

This query had been working fine for a good long time, but suddenly it starts throwing up this message. I haven't changed anything at all with this query. Its very puzzling. I went through each of the fields and its the comment field that is causing the problem.

Would anyone have any ideas on why this might be happening?

Thanks for reading this!

Polo

View 6 Replies View Related

Parameter Query Error: Too Complex To Be Evaluated

Nov 21, 2006

I am getting the following error on my query:

"This expression is typed incorrectly, or it is too complex to be evaluated For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables."

Below is my SQL for this query:

SELECT DISTINCTROW [OI Category Aging Query].[Age List], [OI Category Aging Query].[Reporting Entity], Sum([OI Category Aging Query].[Accrual $]) AS [Sum Of Accrual $], Sum([OI Category Aging Query].Unearned) AS [Sum Of Unearned]
FROM [OI Category Aging Query]
GROUP BY [OI Category Aging Query].[Age List], [OI Category Aging Query].[Reporting Entity];

It's just a simple query to sum up two columns from another query. This query is for an OI Category Aging report, and I have another MI Category Aging report that is working perfectly fine. They almost mirror each other, except for a few calculation differences. They both start from the same table. And my OI Category Aging Query seems to be working just fine. I cannot find any errors or N/A's in either the Accrual $ column or the Unearned column. Any suggestions on what to do or where to go from here? A simple sum on only the Accrual $ column or the Unearned column doesn't work either.

The OI Category Aging Query is 198,711 rows, so I can't drop it into excel.

Any help would be greatly appreciated!

Thanks,
Jason

View 1 Replies View Related

Reports :: Sum Different Fields With Same Format - Too Complex To Be Evaluated

Aug 6, 2013

I am trying to sum 3 different time fields together in a report that all are the same format but it wont allow me to.

The expression i have built is =Sum([ACDTime]+[AgentRingTime]+[OtherTime])

but I get back a error message saying...

"This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables."

View 1 Replies View Related

Queries :: How To Delete Evaluated Data On The Query

Aug 26, 2014

I have a Query which can pull data to a form, then the form will evaluate the ID, after saving/recording, I need to delete the evaluated data on the query.

My problem is how can i delete it? There is Table1 for outputing the evaluation, Query1 where the evaluation can get the Data.

Process Flow:
> Form pulls data from Query1
> Evaluation was saved on Table1
> Evaluated ID should also be removed on Query1

View 1 Replies View Related

Display Variable/Constant Value On Text Box

Sep 15, 2005

Hi all,

I tried to display a variable and constant onto a text box by putting =myvariable onto the data source of the text box. However, Access seems keep threating my variable as a data field and giving me error message. What to do with this?

View 1 Replies View Related

Modules & VBA :: Loop Over Than Declaring Constant

Jun 30, 2015

why my access always go over the loop that I am declaring..Here is a sample of my code:

Code:

Dim rs As New ADODB.Recordset
rs.ActiveConnection = conn
rs.Open mySQL, conn, adOpenDynamic, adLockOptimistic
For lngProd = 1 To 5

[code]...

I get the error of access cannot find the tbl_data6. Where in the declaration I wrote 6??

View 1 Replies View Related

Make A File On Harddrive The Constant Datasource

Jul 29, 2006

Can anyone help me with setting up a Visual Basic project to where the datasource I use is a Access database on my harddrive. This Access database isn't linked to a server or anything. It's just a database I created and would like for my project to open this file everytime it's attempting to pull data. How can I make this connection? If I am able to use ADO, how do I go about doing this? I would think ADO wouldn't be necessary though.

View 1 Replies View Related

Modules & VBA :: Constant Loop With Retry Button

May 29, 2014

I'm trying to do the following with the code below:

1. If the file is not in your My Documents folder than goto errhandler and a message box pops up asking you to retry or cancel.
2. When the user clicks retry it goes back and trys again but if the file still isn't there a runtime error 1004 occurs.

I want it to continue to loop when the user presses retry or until cancel is pressed. I've been trying with the code below but no luck.

Code:

Public Function AddITARPicOffloadAnalysis()
Dim xlApp As Object
Dim wb As Object
Dim ws As Object
Dim Lastrow As Long
Dim objFolders As Object
Set xlApp = CreateObject("Excel.Application")

[Code] ....

View 7 Replies View Related

Forms :: Daily Data Collection With Constant Elements

Jan 26, 2014

I have a table that is populated everyday, with following columns:

1. ward (linked to the wards table)
2. date
3. number of patients

We have a total of 18 wards, wherein the daily number of patient in each ward should be recorded. The problem we face is that we find it counter-productive if the data encoder selects a specific ward (dropdown list), then puts the number of patients, and then moves to another field repeating the process. (the date is pre-selected using a combo-box and this will fill the date fields, thus the encoder selects the date only once).

I was wondering if there is a way where we can just automatically show all the wards, so that the data encoder would just proceed on putting the figures.

View 2 Replies View Related

Calculation In A Report - Subtract Calculated Number From A Constant

Aug 25, 2011

I have a column with a sum total in the footer. I would like to subtract this calculated number from a constant (i.e., 20,000.00). Is this possible?

View 3 Replies View Related

Something Like A "Current Control" Constant?

Aug 27, 2007

Hi, I am using a macro in order to change a value after a control has been updated (using the AfterUpdate field). The problem is that I would like to use a single macro for all the controls (since the macro does the same thing on every control and I have many controls), not a new macro every time (nor a macro with many rows); is there any way to put into an expression something like "Current Control" constant instead of [Forms]![New]![Surname], [Forms]![New]![Name] etc...? something like [Forms]![New]![CurrentControl]? Thanks.

View 7 Replies View Related

Date Problem - Part Constant - Part Now()

Nov 3, 2006

Hi everyone,

I have refined my query from previous threads to involved a module function. This calculates more acurately no of working days between dates and takes into account a holidays table. (All credit to Arvin Meyer on the module:) )
However because the Leave Year starts at the 1 July and finishes 30 Jun I need to compose the date for any current year Year(Now())

Enclosed scrdmp shows my query design. I can easily get it to work as you see it, but obviously as each year rolls over, the year needs to change.

Have looked at many posts but can't find what I'm looking for. This one will get me over the hurdle.

Many thanks,

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved