A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Call function from query 'Criteria' line.



 
 
Thread Tools Display Modes
  #1  
Old December 11th, 2009, 05:13 PM posted to microsoft.public.access.queries
Breecy via AccessMonster.com
external usenet poster
 
Posts: 18
Default Call function from query 'Criteria' line.

I am trying to call a Public function from the criteria line in the design
view of the query builder in Access 2003. I will try and recreate the look:

Field: Account_ID Control_Date
Table: Historical_Table Historical_Table
Sort:
Show: (checkmarked) (checkmarked)
Criteria: "999999" GetDate()



Public Function getdate() As Date
GetDate = "#" & Date & "#"
End Function

When I try and run it, I receive the error : Undefined function 'GetDate' in
expression. What am I doing wrong? Is it not possible to do this?

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200912/1

  #2  
Old December 11th, 2009, 05:43 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Call function from query 'Criteria' line.

Is GetDate in a VBA module and not in a form or report module? It should be
in VBA module.

Your function should be more like

Public Function getdate() As Date
GetDate = Date
End Function

Adding the "#" at the beginning and ending turns the data type into a string.
And then you will get a error #13 Type mismatch when you try to assign that to
GetDate to return the value.


John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Breecy via AccessMonster.com wrote:
I am trying to call a Public function from the criteria line in the design
view of the query builder in Access 2003. I will try and recreate the look:

Field: Account_ID Control_Date
Table: Historical_Table Historical_Table
Sort:
Show: (checkmarked) (checkmarked)
Criteria: "999999" GetDate()



Public Function getdate() As Date
GetDate = "#" & Date & "#"
End Function

When I try and run it, I receive the error : Undefined function 'GetDate' in
expression. What am I doing wrong? Is it not possible to do this?

  #3  
Old December 11th, 2009, 06:05 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Call function from query 'Criteria' line.

Are you wanting to use current date or is 'Date' in your function a field in
your record?
If current date then use -- Date()
If a field in record use -- [Date]

BTW 'date' is a reserved word and may cause problems.

--
Build a little, test a little.


"Breecy via AccessMonster.com" wrote:

I am trying to call a Public function from the criteria line in the design
view of the query builder in Access 2003. I will try and recreate the look:

Field: Account_ID Control_Date
Table: Historical_Table Historical_Table
Sort:
Show: (checkmarked) (checkmarked)
Criteria: "999999" GetDate()



Public Function getdate() As Date
GetDate = "#" & Date & "#"
End Function

When I try and run it, I receive the error : Undefined function 'GetDate' in
expression. What am I doing wrong? Is it not possible to do this?

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200912/1

.

  #4  
Old December 11th, 2009, 06:44 PM posted to microsoft.public.access.queries
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default Call function from query 'Criteria' line.

Breecy -

Why don't you just use = Date() in the criteria?

Your problem is with your function, which is typed to return a date, but
then you are appending the pound signs before and after the date and trying
to return that (which is no longer a date).

--
Daryl S


"Breecy via AccessMonster.com" wrote:

I am trying to call a Public function from the criteria line in the design
view of the query builder in Access 2003. I will try and recreate the look:

Field: Account_ID Control_Date
Table: Historical_Table Historical_Table
Sort:
Show: (checkmarked) (checkmarked)
Criteria: "999999" GetDate()



Public Function getdate() As Date
GetDate = "#" & Date & "#"
End Function

When I try and run it, I receive the error : Undefined function 'GetDate' in
expression. What am I doing wrong? Is it not possible to do this?

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200912/1

.

  #5  
Old December 11th, 2009, 08:04 PM posted to microsoft.public.access.queries
Breecy via AccessMonster.com
external usenet poster
 
Posts: 18
Default Call function from query 'Criteria' line.

I am actually in the design view of a new query. I wish I could past
pictures in here I have what is in the query and then what the public
Function looks like. I would like to use date(), but when I do I get no
result, but if I manually type in #12/10/2009# into the query criteria it
works like a champ. I was hoping to put it in the return of the fuction so
it would work.

I can put an SQL statement in code and make this work, but I wanted to call
the function from the criteria line of the query. Make sense?

Daryl S wrote:
Breecy -

Why don't you just use = Date() in the criteria?

Your problem is with your function, which is typed to return a date, but
then you are appending the pound signs before and after the date and trying
to return that (which is no longer a date).

I am trying to call a Public function from the criteria line in the design
view of the query builder in Access 2003. I will try and recreate the look:

[quoted text clipped - 11 lines]
When I try and run it, I receive the error : Undefined function 'GetDate' in
expression. What am I doing wrong? Is it not possible to do this?


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200912/1

  #6  
Old December 11th, 2009, 09:57 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Call function from query 'Criteria' line.

Is Control_Date DateTime datatype?
Put this in your query grid to see what is returned --
My_Date_Test: CDbl([Control_Date])
and
My_Date_DblCk_Test: CVDate(CDbl([Control_Date]))


--
Build a little, test a little.


"Breecy via AccessMonster.com" wrote:

I am actually in the design view of a new query. I wish I could past
pictures in here I have what is in the query and then what the public
Function looks like. I would like to use date(), but when I do I get no
result, but if I manually type in #12/10/2009# into the query criteria it
works like a champ. I was hoping to put it in the return of the fuction so
it would work.

I can put an SQL statement in code and make this work, but I wanted to call
the function from the criteria line of the query. Make sense?

Daryl S wrote:
Breecy -

Why don't you just use = Date() in the criteria?

Your problem is with your function, which is typed to return a date, but
then you are appending the pound signs before and after the date and trying
to return that (which is no longer a date).

I am trying to call a Public function from the criteria line in the design
view of the query builder in Access 2003. I will try and recreate the look:

[quoted text clipped - 11 lines]
When I try and run it, I receive the error : Undefined function 'GetDate' in
expression. What am I doing wrong? Is it not possible to do this?


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200912/1

.

  #7  
Old December 14th, 2009, 11:11 PM posted to microsoft.public.access.queries
Breecy via AccessMonster.com
external usenet poster
 
Posts: 18
Default Call function from query 'Criteria' line.

Here is a subset of the data that is returned:

ACCOUNT_ID CONTROL_DATE NET_ASSETS My_Date_Test My_Date_DblCk_Test
100601 3/3/2009 0 39875 3/3/2009
100601 3/4/2009 0 39876 3/4/2009
100601 3/5/2009 0 39877 3/5/2009
100601 3/6/2009 0 39878 3/6/2009
100601 3/9/2009 0 39881 3/9/2009
100601 3/10/2009 0 39882 3/10/2009
100601 3/11/2009 0 39883 3/11/2009
100601 3/12/2009 0 39884 3/12/2009
100601 3/13/2009 0 39885 3/13/2009
100601 3/16/2009 0 39888 3/16/2009
100601 3/17/2009 0 39889 3/17/2009
100601 3/18/2009 0 39890 3/18/2009
100601 3/19/2009 0 39891 3/19/2009
100601 3/20/2009 0 39892 3/20/2009
100601 3/23/2009 0 39895 3/23/2009
100601 3/24/2009 0 39896 3/24/2009
100601 3/25/2009 0 39897 3/25/2009
100601 3/26/2009 0 39898 3/26/2009
100601 3/27/2009 0 39899 3/27/2009
100601 3/30/2009 0 39902 3/30/2009
100100 3/31/2009 0 39903 3/31/2009
100101 3/31/2009 0 39903 3/31/2009
100102 3/31/2009 0 39903 3/31/2009
100103 3/31/2009 0 39903 3/31/2009
100104 3/31/2009 0 39903 3/31/2009
100105 3/31/2009 0 39903 3/31/2009
100106 3/31/2009 0 39903 3/31/2009
100107 3/31/2009 0 39903 3/31/2009
100108 3/31/2009 0 39903 3/31/2009
100109 3/31/2009 0 39903 3/31/2009
100110 3/31/2009 0 39903 3/31/2009


What is this data telling me?

KARL DEWEY wrote:
Is Control_Date DateTime datatype?
Put this in your query grid to see what is returned --
My_Date_Test: CDbl([Control_Date])
and
My_Date_DblCk_Test: CVDate(CDbl([Control_Date]))

I am actually in the design view of a new query. I wish I could past
pictures in here I have what is in the query and then what the public

[quoted text clipped - 19 lines]
When I try and run it, I receive the error : Undefined function 'GetDate' in
expression. What am I doing wrong? Is it not possible to do this?


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200912/1

  #8  
Old December 15th, 2009, 01:17 AM posted to microsoft.public.access.queries
raskew via AccessMonster.com
external usenet poster
 
Posts: 370
Default Call function from query 'Criteria' line.

Hi -

My_Date_Test is returning the date as it is stored internally by Access.

Try pasting this into the SQL view of a new query.

SELECT Account_ID, Control_Date
FROM Historical_Table
WHERE (((Control_Date)=Date()));

Bob

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200912/1

  #9  
Old December 15th, 2009, 02:47 PM posted to microsoft.public.access.queries
Breecy via AccessMonster.com
external usenet poster
 
Posts: 18
Default Call function from query 'Criteria' line.

But if it don't recognize the function then it doesn't matter how I format is
passed back, does it.

John Spencer wrote:
Is GetDate in a VBA module and not in a form or report module? It should be
in VBA module.

Your function should be more like

Public Function getdate() As Date
GetDate = Date
End Function

Adding the "#" at the beginning and ending turns the data type into a string.
And then you will get a error #13 Type mismatch when you try to assign that to
GetDate to return the value.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

I am trying to call a Public function from the criteria line in the design
view of the query builder in Access 2003. I will try and recreate the look:

[quoted text clipped - 11 lines]
When I try and run it, I receive the error : Undefined function 'GetDate' in
expression. What am I doing wrong? Is it not possible to do this?


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200912/1

  #10  
Old December 15th, 2009, 02:49 PM posted to microsoft.public.access.queries
Breecy via AccessMonster.com
external usenet poster
 
Posts: 18
Default Call function from query 'Criteria' line.

Also all I should have stated before, but if the date that I am pulling is a
holiday, I want to be able to specify the date that I want to use.

raskew wrote:
Hi -

My_Date_Test is returning the date as it is stored internally by Access.

Try pasting this into the SQL view of a new query.

SELECT Account_ID, Control_Date
FROM Historical_Table
WHERE (((Control_Date)=Date()));

Bob


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200912/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.